【问题标题】:IIS 7 and font awesome .woff 404 errorIIS 7 和字体真棒 .woff 404 错误
【发布时间】:2016-09-29 23:32:45
【问题描述】:

尝试在我的 MVC 5 应用程序中加载 .woff.woff2.ttf 文件时遇到 404 错误。在我遇到同样错误的post 的指导下,似乎没有什么对我有用。以下是我目前拥有的:

在我的网络配置文件中

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

在 IIS 中,我做了以下步骤:

  1. 在连接下,选择 MIME 类型
  2. 右键单击并选择“添加...”
  3. 对于每个文件类型,文件扩展名:.woff MIME 类型:font/x-woff

错误发生在 IE 11 和 Chrome 中。请帮助我如何纠正这个问题。

【问题讨论】:

  • Firefox 能正确加载它们吗?
  • 我知道您使用的是 IIS7,但您尝试过这些建议吗?似乎使用 application/font-woff2 而不是 font/x-woff2 可能会起作用:stackoverflow.com/questions/25796609/…

标签: css asp.net-mvc iis font-face font-awesome


【解决方案1】:

经过更多研究,无法正确加载的原因是捆绑。在我的文件中有以下内容:

在我的 BundleConfig.cs 中:

bundles.Add(new StyleBundle("~/font-awesome/css").Include("~/fonts/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransform()));

在我的 _Layout.cshtml 文件中:

@Styles.Render("~/font-awesome/css")

我删除了上面的两段代码,直接在_Layout.cshtml文件中添加了font awesome文件:

<link href="~/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-20
    • 2021-08-21
    • 2013-06-19
    • 2016-02-10
    • 1970-01-01
    • 2020-09-24
    • 2019-02-12
    • 2021-06-04
    相关资源
    最近更新 更多