• IIS无法加载字体文件(*.woff,*.svg)的解决办法


    在编写前端代码的过程中经常会遇到使用特定的字体(*.woff,*.svg),此时在加载字体时请求会被返回

    Failed to load resource: the server responded with a status of 404 (Not Found)。

    原因是,默认在IIS上是没有添加对*.woff,*.svg文件的Mime类型,因此在客户端请求此类文件时得到的都是404。

    所以我们只需要在我们对应网站下的Mime类型中添加文件对应的类型就行了

    1. .woff  application/x-font-woff
    2. .woff2 application/x-font-woff
    3. .svg   image/svg+xml

    另外在mvc中,设置了上述Mime类型后get请求字体时任然会出现404的问题,这个时候需要在我们的web工程中的config的system.webServer节点中添加如下的代码来支持

    <staticContent>
          <remove fileExtension=".woff"/>
          <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
          <remove fileExtension=".woff2"/>
          <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
          <remove fileExtension=".ttf" />
          <mimeMap fileExtension=".ttf" mimeType="application/x-font-truetype" />
          <remove fileExtension=".svg" />
          <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
          <remove fileExtension=".otf" />
          <mimeMap fileExtension=".otf" mimeType="application/x-font-opentype" />
          <remove fileExtension=".eot" />
          <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
    </staticContent>

  • 相关阅读:
    python中的面向对象编程
    python global vs nonlocal (2)
    python3 nonlocal vs global
    poj蚂蚁问题
    C/C++ static vs global
    砝码问题
    Wythoff's game
    C++中的::operator new, ::operator delete
    客户信息表 自我汇总 待确认
    Oracle Savepoint
  • 原文地址:https://www.cnblogs.com/pocn/p/5468783.html
Copyright © 2020-2023  润新知