IE tries to download json response while submitting jQuery multipart form data containing file IE tries to download json response while submitting jQuery multipart form data containing file json json

IE tries to download json response while submitting jQuery multipart form data containing file


You can simply return JSON from the controller as "text/html" and then parse it on the client side using JQuery.parseJSON().

Controller:

    return this.Json(            new                {                    prop1 = 5,                    prop2 = 10                },             "text/html");

Client side:

jsonResponse = $.parseJSON(response);if(jsonResponse.prop1==5) {     ...}

This solution has been working for me.


I have not found a direct solution to this, but I eventually implemented the following workaround: I used dataType: "text" in my ajax settings and then returned plaintext from controller, separating values with ; and parsing them on the client side. That way IE and Forefox stopped trying to download a response.

I did not find any other way to prevent said behavior other then to return plaintext. I tried returning JSON as plaintext and then parsing it with $.parseJSON, but it didn't work due to some js errors.


Just send response with 'Content-Type', 'text/html' header.