Search code examples
asp.netfile-uploadashx

context.Request.Files collection empty on remote server only


I'm using a custom ashx handler to handle a file upload. When run locally, the file uploads fine. When I use the same setup on the web server I get a "Index out of range" error. In firebug I see the binary contents of the file in the post data and the file name is also passed in the query string. Any one seen this before? I`m sure its something minor, but its driving me up the wall.

Update: Made some progress. I found out that I'm getting two different errors. One from FF / Chrome and one from IE. I'm focusing on FF now, just because firebug makes debugging easier. Now I get an error "Could not find a part of the path 'C:\inetpub\wwwroot\'"

Update 2: Got this working in FF/Chrome. Turns out IE and FF/Chrome post the data differentlly.

Update 3: Here is the output of the network profiler in IE dev tool:

Request header:
Key Value
Request POST /Secured/UploadHandler.ashx? HTTP/1.1
Accept  text/html, application/xhtml+xml, */*
Referer http://cms.webstreet.co.il/Secured/fileUpload.aspx
Accept-Language he-IL
User-Agent  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type    multipart/form-data; boundary=---------------------------7db13b13d1b12
Accept-Encoding gzip, deflate
Host    cms.webstreet.co.il
Content-Length  262854
Connection  Keep-Alive
Cache-Control   no-cache

Request body:
-----------------------------7db13b13d1b12
Content-Disposition: form-data; name="qqfile"; filename="P-Art_Page_Digital.jpg"
Content-Type: image/jpeg

<Binary File Data Not Shown>
---------------------------7db13b13d1b12--

Solution

  • See the (big) list of comments and replies attached to the original question. Not sure why it works now, but Elad seems to have fixed his problem.