在runAllManagedModulesForAllRequests设置为true的情况下,如何在IIS 7中禁用flv文件的gzip压缩?

Aus*_*tin 5 c# asp.net iis-7 gzip web-config

我有一个在IIS 7上运行的ASP.NET 3.5网站,我希望压缩gzip的静态内容(例如css文件,javascript文件等)以及动态内容(.net页面)。问题是我需要确保未对flv文件(Flash视频文件)进行gzip压缩,因为这会导致我正在使用的Flash Video Player Flowplayer出现问题

我在web.config中添加了以下行,以启用压缩功能,但随后我的flv文件也被gzip压缩了:

<urlCompression doStaticCompression="true" doDynamicCompression="true" />
Run Code Online (Sandbox Code Playgroud)

我尝试将以下内容添加到我的web.config中,但它没有任何改变:

<httpCompression>
    <staticTypes>
        <remove mimeType="video/x-flv"/>
    </staticTypes>
    <dynamicTypes>
        <remove mimeType="video/x-flv"/>
    </dynamicTypes>
</httpCompression>
Run Code Online (Sandbox Code Playgroud)

我必须关闭doDynamicCompression才能使flv文件不会被gzip压缩。我认为它会将flv文件视为动态内容,因为我在web.config中拥有了runAllManagedModulesForAllRequests =“ true”(我需要做一些与路由有关的事情)。

总之,如何为flv文件禁用gzip压缩?

dev*_*rts 2

我认为最好的办法是手动管理 gzip 压缩的内容。有时,经过 gzip 压缩的内容实际上会增加大小,例如 swf,这就是我刚刚遇到的情况。以前我的application.config里面有这个块,在我删除冲击波 mime 类型的 swf 后停止压缩

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <dynamicTypes>
                <clear />
                <add mimeType="text/*" enabled="true" />
                <add mimeType="message/*" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true" />
                <add mimeType="application/x-amf" enabled="true" />
                <add mimeType="application/json" enabled="true" />
                <add mimeType="application/json; charset=utf-8" enabled="true" />
                <add mimeType="application/x-shockwave-flash" enabled="true" /> <!-- notice the swf mime type -->
                <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <staticTypes>
                <clear />
                <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="application/x-shockwave-flash" enabled="true" /> <!-- notice the swf mime type -->
                <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>
Run Code Online (Sandbox Code Playgroud)

这是在我的应用程序配置中,windows\system32\intersrv\config\application.config但我很确定您可以在 web.config 下的每个网站上执行此操作system.webserver

我所要做的就是删除冲击波哑剧类型,它不再被压缩,但所有其他有效的哑剧类型都被压缩了。