Asp.net web api IIS中OData的压缩

Asp.net web api IIS中OData的压缩,asp.net-web-api,odata,Asp.net Web Api,Odata,我在IIS7中使用动态压缩,并在配置中启用以下行: <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> <staticTypes> <add

我在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>
回答是这样的:

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
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

我假设您发布的配置是应用程序的web.config。最简单的解决方案是将配置的dynamicTypes中的“add mimeType=“/”enabled=“false”更改为“add mimeType=“/”enabled=“true”。如果行得通,你可以试试

另一个解决方案是更改IIS管理器中的配置。您可以按照以下步骤操作: