IIS忽略system.webServer staticContent节 [英] IIS ignores system.webServer staticContent section

查看:1226
本文介绍了IIS忽略system.webServer staticContent节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UDPATE

在心血来潮,我决定把4字体文件上传到字体转换器。我转换的fontsfrom TTF TTF来,然后试了一下。一切工作正常:内容类型设置是否正确和X​​供电-By头被删除结果。
奇怪的。


我试图更改.TTF文件的MIME类型(内容类型头)在web.config中的IIS7。

下面是里面的staticContent节< system.webServer />

 < staticContent>
    <TTF删除fileExtension = />
    < mimeMap fileExtension = mime类型=FONT / TTF/&GTTTF;
< / staticContent>

即使具有上述结构的所有的.ttf文件与应用程序/ octetstream发送。

我也有如下的customHeader部分:

 <删除名称=X供电,通过/>

它成功地消除了对CSS,PNG,JPG,GIF,ICO,的.aspx,名为.htm或.html的 X-技术,通过头,SHTML,和js文件。这不,但是,连续工作的.ttf。

任何人都知道我在做什么错了?


我的整个web.config文件,以防万一:

 <?XML版本=1.0编码=UTF-8&GT?;
<! -
    注意:作为一种替代手工编辑这个文件,你可以使用
    Web管理工具来配置应用程序的设置。使用
    该网站 - >在Visual Studio中Asp.Net配置选项。
    设置和注释的完整列表中可以找到
    machine.config.comments通常位于
    \\ WINDOWS \\ Microsoft.Net \\框架\\ V2.X \\配置
- >
<结构>  <系统codeDOM>
    <编译器>
      <编译语言=C#; CS; CSHARPCS延长= warningLevel =4TYPE =Microsoft.CSharp.CSharp codeProvider,系统,版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089>
        < providerOption NAME =CompilerVersionVALUE =V3.5/>
        < providerOption NAME =warnaserror将值=FALSE/>
      < /编译器>
    < /编译器>
  < /system.$c$cdom>
  <! -
        的system.webServer部分需要在Internet上运行ASP.NET AJAX
        信息服务7.0。这是没有必要的IIS的previous版本。
     - >
  < system.webServer>
    <验证validateIntegratedModeConfiguration =FALSE/>
    < httpProtocol>
      < customHeaders>
        <删除名称=X供电,通过/>
        <添加名称=X-UA-Compatible的值=铬= 1; IE =边缘/>
      < / customHeaders>
    < / httpProtocol>
    <模块>
      <清除NAME =会话/>
      <清除NAME =WindowsAuthentication/>
      <清除NAME =FormsAuthentication/>
      <清除NAME =PassportAuthentication/>
      <清除NAME =RoleManager/>
      <清除NAME =UrlAuthorization/>
      <清除NAME =FileAuthorization/>
      <清除NAME =AnonymousIdentification/>
      <删除名称=档案/>
    < /模块>
    < staticContent>
        <TTF删除fileExtension = />
        < mimeMap fileExtension = mime类型=FONT / TTF/&GTTTF;
    < / staticContent>
  < /system.webServer>
  <&运行GT;
    < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1appliesTo =V2.0.50727>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Extensions程序公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-1.1.0.0NEWVERSION =3.5.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Extensions.Design公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-1.1.0.0NEWVERSION =3.5.0.0/>
      < / dependentAssembly>
    < / assemblyBinding>
  < /运行>
< /结构>


解决方案

此修复程序是设置 runAllManagedModulesForAllRequests 真正

 < system.webServer>
    <模块runAllManagedModulesForAllRequests =真正的>
        <! - 东西 - >
    < /模块>
< /system.webServer>

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="UrlAuthorization" />
      <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>

这篇关于IIS忽略system.webServer staticContent节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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