I am trying to upload a file and return a json response regarding properties(name, size etc) of the file. It works fine in all browsers except IE.
IE tries to download the JSON as a file !
I have IE10 and testing it on IE7 to 10 by changing browser mode and document mode from the debugger.
I am using asp.net mvc4, the file upload action have HttpPost attribute and i am returning json response using return Json(myObject);
And here are my http headers
Request POST /File/UploadFile/ HTTP/1.1
Accept text/html, application/xhtml+xml, */*
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Content-Type multipart/form-data; boundary=---------------------------7dc1e71330526
Accept-Encoding gzip, deflate
Response HTTP/1.1 200 OK
Server ASP.NET Development Server/18.104.22.168
Date Tue, 18 Dec 2012 23:44:19 GMT
Content-Type application/json; charset=utf-8
I tried a few suggestions but so far back to square one !
You will need to return the json as
text/html since IE does not know what to do with
return Json(myObject, "text/html");
Not sure but it might work (and it would be more correct if it does) to use
return Json(myObject, "text/x-json");