MVC发布到IIS后无法找到字体文件

dre*_*att 3 css c# asp.net-mvc asp.net-mvc-4

Franework ASP.Net MVC 4

这是"直到我发表才有效"的另一个例子.

从Visual Studio运行我的MVC 4站点,一切都很好.然而,当我发布 - 字体真棒休息.看看Chrome控制台,我看到了这个:

GET http://localhost:4321/Content/themes/crisp/font/zocial.woff?94486700 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

在我的CSS中引用了这样的:

@font-face {
  font-family: 'zocial';
  src: url('/Content/themes/crisp/font/zocial.eot?94486700');
  src: url('/Content/themes/crisp/font/zocial.woff?94486700') format('woff'),
       url('/Content/themes/crisp/font/social.ttf?94486700') format('truetype'),
       url('/Content/themes/crisp/font/zocial.svg?94486700#fontello') format('svg');
  font-weight: normal;
  font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)

我已经检查过 - 文件在网站目录中:

在此输入图像描述

我究竟做错了什么?

Ste*_*n V 7

我有一种感觉,您需要将MIME类型添加到应用程序的web.config(或在IIS管理器中全局).

尝试添加:

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
        <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
        <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
    </staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

到你的web.config.

如果遇到重复的密钥问题,这意味着您的IIS实例已经具有某些扩展.要允许您控制所有扩展的MIME类型,请添加:

<remove fileExtension=".woff" />
<remove fileExtension=".eot" />
<remove fileExtension=".svg" />
<remove fileExtension=".ttf" />
Run Code Online (Sandbox Code Playgroud)

<mimeMap>元素之前.