I have written a MVC3 application in which I use Valums fileuploader. When a user uploads a file, the server passes back a JSON object indicating success/failure and possibly an error message. Some users are reporting that their browser asks them for action as if downloading a file (save/open), instead of passing the JSON to the javascript.
I’m using the uploader as distributed, and my C# controller returns a JSONResult like this
return JSON(new { success = true }, "application/json");
Or if something goes wrong
return JSON(new { success = false, error = exception.Message });
I have been unable to reproduce this, and have gotten reports from users of both IE9 and Chrome. Has anyone had this happen, and what did you do to solve it? Or where should I start troubleshooting?
EDIT:
The file uploader will run this on the onComplete event:
function(id, filename, responseJson) {
if(responseJson.success != true) {
alert("An error occurred: " + responseJson.error);
return false;
}
return true;
}
Turns out the problem is that IE does not handle the
application/jsoncontent type. Setting it totext/htmlmakes it work, although it is quite awful.