[英]Compression of OData in IIS
I use dynamic compression in IIS7 and enabled the following lines in the configuration: 我在IIS7中使用动态压缩,并在配置中启用了以下几行:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
<add mimeType="application/json; odata=fullmetadata; charset=utf-8" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimetype="application/atom+xml" enabled="true">
<add mimetype="application/atom+xml;charset=utf-8" enabled="true">
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
</httpCompression>
I have an OData controller in Web API which is based off a ODataController
. 我在Web API中有一个基于
ODataController
的OData控制器。
The OData part work fine, but dynamic compression seems not to work on them, the request looks like this: OData部分工作正常,但动态压缩似乎无法对其进行处理,该请求如下所示:
Accept:application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,nl;q=0.6
Connection:keep-alive
DataServiceVersion:3.0
MaxDataServiceVersion:3.0
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
X-SchemaVersion:2.0.0.265
And the response like this: 和这样的响应:
Cache-Control:no-cache
Content-Length:34862
Content-Type:application/json; odata=fullmetadata; charset=utf-8
DataServiceVersion:3.0
Date:Wed, 11 Jun 2014 16:35:12 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
I suppose the config you posted are web.config of your application. 我想您发布的配置是应用程序的web.config。 The most easy solution is to changed "add mimeType=" / " enabled="false"" to "add mimeType=" / " enabled="true"" in dynamicTypes of config.
最简单的解决方案是在配置的dynamicTypes中将“ add mimeType =“ / ” enabled =“ false”“更改为” add mimeType =“ / ” enabled =“ true”“。 You can try if it works.
您可以尝试是否可行。
Another solution is to change the config in IIS manager. 另一个解决方案是更改IIS管理器中的配置。 you can follow: Here
您可以关注: 这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.