IIS ignores system.webServer staticContent section
UDPATE
On a whim, I decided to upload the 4 fonts files to an font converter. I converted the fontsfrom ttf to ttf and then tried it. Everything works fine: the Content-Type is set correctly and the X-Powered-By header is removed.
Weird.I am trying to change the mime type (Content Type header) of a .ttf file in web.config on IIS7.
Here is the staticContent section inside <system.webServer />
:
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
</staticContent>
Even with the above configuration all .ttf files are sent with application/octetstream.
I also have a customHeader section with the following:
<remove name="X-Powered-By" />
which successfully removes the X-Powered-By
header for css, png, jpg, gif, ico, .aspx, .htm, .html, shtml, and js files. It does NOT, however, work for .ttf.
Anyone know what I'm doing wrong?
My entire web.config just in case:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5" />
<providerOption name="WarnAsError" value="false" />
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<add name="X-UA-Compatible" value="chrome=1;IE=edge" />
</customHeaders>
</httpProtocol>
<modules>
<remove name="Session" />
<remove name="WindowsAuthentication" />
<remove name="FormsAuthentication" />
<remove name="PassportAuthentication" />
<remove name="RoleManager" />
<remove name="Ur开发者_Go百科lAuthorization" />
<remove name="FileAuthorization" />
<remove name="AnonymousIdentification" />
<remove name="Profile" />
</modules>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
</staticContent>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
The fix was to set runAllManagedModulesForAllRequests
to true
.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<!-- stuff -->
</modules>
</system.webServer>
精彩评论