在web.config中添加MIME映射IIS防爆preSS [英] Add MIME mapping in web.config for IIS Express

查看:254
本文介绍了在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://stackoverflow.com/a/5142316/135441

更新2013年4月10日

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

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

这篇关于在web.config中添加MIME映射IIS防爆preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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