Showing posts with label json IE MVC. Show all posts
Showing posts with label json IE MVC. Show all posts

Friday, June 24, 2011

IE Tries to Download Json Response

Apparently, IE 8 and below doesn't like "application/json" mime type in ajax response. When it receives the response, it tries to download it as a file, and prompts a "Save as" dialogue. Although the standard json mime type is "Application/json", you need to use "text/plain" to fix this issue, So if you are using .Net MVC you need to use:
return Json(result, "text/plain");

Where "result" is the object you want to convert to Json.

Important: Do not use "text/html", it creates an XSS flaw in your application. See here for more info