Using. net WEBAPI to return Application/json type causes IE8 prompt download

Source: Internet
Author: User
<span id="Label3"></p><p><p>1, Scene Introduction</p></p><p><p>The project uses the Jquery.form.js plugin, which submits the information in the form form in an AJAX manner. Because you need to use Ajax to get the return Information. Data entry uses The. net MVC method of the WEBAPI data interface for commit Input.</p></p><p><p></p></p><p><p>2, question</p></p><p><p>In IE 8 and the following version encountered, after the successful submission, the data returned to the format is: application/json, in IE 8 (including) The following version of the direct prompt to download the Json.</p></p><p><p></p></p><p><p>3, Workaround</p></p><p><p>Modify the WebApiConfig.cs in the App_start folder in the System. Delete response type: application/json Add File type text/html or text/plain, my modified configuration is modified as follows</p></p><pre><pre> Config. Formatters.JsonFormatter.SupportedMediaTypes.Remove (<span style="color: #0000ff;">new</span> mediatypeheadervalue (<span style="color: #800000;">"</span><span style="color: #800000;">Application /json</span><span style="color: #800000;">"</span><span style="color: #000000;">)); Config. FORMATTERS.JSONFORMATTER.SUPPORTEDMEDIATYPES.ADD (</span><span style="color: #0000ff;">new</span> mediatypeheadervalue (<span style="color: #800000;">"</span><span style="color: #800000;">text/html </span><span style="color: #800000;">"</span><span style="color: #000000;">)); Config. Formatters.remove (config. formatters.formurlencodedformatter); Config. Formatters.remove (config. formatters.xmlformatter);</span></pre></pre><p><p></p></p><p><p>Using. net WEBAPI to return Application/json type causes IE8 prompt download</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.