在web.config中添加MIME映射IIS防爆preSS

问题描述:

我需要添加一个新的MIME映射.woff文件扩展名IIS防爆preSS。

I need to add a new MIME mapping for .woff file extensions to IIS Express.

如果我添加下面的代码片段到IIS防爆preSS的对ApplicationHost.config它工作正常:

If I add the following snippet to the "applicationhost.config" of IIS Express it works fine:

<staticContent lockAttributes="isDocFooterFileName">
    <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
    ...

但我真的喜欢做它添加到我的web.config,这样不是每个开发人员需要改变他们对ApplicationHost.config本地。

But I would actually like to do add it to my "web.config" so that not every developer would need to change their "applicationhost.config" locally.

所以,我从对ApplicationHost.config文件再次删除,并添加下面的代码片段到项目的web.config中

So I removed it again from the "applicationhost.config" file and added the following snippet to the project's "web.config":

<system.webServer>
  ...
  <staticContent>
    <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
  </staticContent>
</system.webServer>

不幸的是它似乎并没有工作,那是因为当我试图访问一个文件.woff我结束了一个HTTP 404.3错误。

Unfortunately it doesn't seem to work that way because when I try to access a .woff file I end up with a HTTP 404.3 error.

我在做什么错了?

将它放到的web.config工作正常。问题是,我得到的MIME类型是错误的。取而代之的 字体/ X-WOFF 击>或 字体/ X-字体WOFF 击>它必须 应用程序/字体WOFF

Putting it in the "web.config" works fine. The problem was that I got the MIME type wrong. Instead of font/x-woff or font/x-font-woff it must be application/font-woff:

<system.webServer>
  ...
  <staticContent>
    <remove fileExtension=".woff" />
    <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
  </staticContent>
</system.webServer>

又见关于MIME类型这样的回答: http://*.com/a/5142316/135441

更新2013年4月10日

规格现在是一个建议,MIME类型正式: 应用程序/字体 - WOFF

Spec is now a recommendation and the MIME type is officially: application/font-woff