gpt4 book ai didi

c# - 发布到 IIS 后,MVC 无法找到字体文件

转载 作者:行者123 更新时间:2023-11-30 13:57:06 24 4
gpt4 key购买 nike

Franework ASP.Net MVC 4

这是“在我发布之前一直有效”的另一个例子。

从 Visual Studio 运行我的 MVC 4 网站,一切正常。但是,当我发布时 - Font Awesome 中断。查看 Chrome 控制台,我看到了这个:

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

在我的 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;
}

我已经检查过 - 文件位于站点目录中:

enter image description here

我做错了什么?

最佳答案

我觉得您需要将 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>

到您的 web.config。

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

<remove fileExtension=".woff" />
<remove fileExtension=".eot" />
<remove fileExtension=".svg" />
<remove fileExtension=".ttf" />

<mimeMap> 之前元素。

关于c# - 发布到 IIS 后,MVC 无法找到字体文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22768875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com