我怎样才能得到ASP.NET AJAX发送它使用gzip COM pression JSON响应? [英] How can I get ASP.NET AJAX to send its JSON response with GZip compression?

查看:117
本文介绍了我怎样才能得到ASP.NET AJAX发送它使用gzip COM pression JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS7启用COM pression和它的作品如预期上除了由ASP.NET AJAX构建的所有答复。我有一个Web服务,将数据提供给客户端。当Web服务的直接调用,这是正确的COM pressed。然而,当它是通过ASP.NET AJAX调用,JSON响应不是玉米pressed

I have compression enabled within IIS7 and it works as expected on all responses except for those constructed by ASP.NET AJAX. I have a web service that provides data to the client. When the web service is called directly, it is properly compressed. However, when it is called via ASP.NET AJAX, the JSON response is not compressed.

我怎样才能得到ASP.NET AJAX发送它使用gzip COM pression JSON响应?

How can I get ASP.NET AJAX to send its JSON response with GZip compression?

推荐答案

IIS7使用内容编码,以决定是否对COM preSS的响应(假设当然,该浏览器可以接受gzip压缩的)。他们中的applicationHost.config设置,默认情况下该列表是

IIS7 uses the content-encoding to decide whether to compress the response (assuming of course that the browser can accept gzip). They're set in applicationHost.config, and by default the list is

<dynamicTypes>
     <add mimeType="text/*" enabled="true" />
     <add mimeType="message/*" enabled="true" />
     <add mimeType="application/x-javascript" enabled="true" />
     <add mimeType="*/*" enabled="false" />
</dynamicTypes>

如果你直接调用Web服务,XML响应有一个内容类型的为text / xml ,它获取COM pressed。当AJAX调用,JSON响应有应用程序/ JSON 的内容类型,所以它不是COM pressed。加入以下的applicationHost.config应解决这个问题...

If you call the web service directly, the XML response has a content-type of text/xml, which gets compressed. When called by AJAX, the JSON response has a content type of application/json, so it isn't compressed. Adding the following to applicationHost.config should fix that...

     <add mimeType="application/json" enabled="true" />

这篇关于我怎样才能得到ASP.NET AJAX发送它使用gzip COM pression JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆