在 Orchard cms 中加载 font.woff 资源时浏览器控制台出现内部服务器错误

Internal server error in browser console when loading font.woff resource in Orchard cms

我用Orchard CMS 1.10.1。我在自定义主题的 Content 文件夹中创建了一个 font 文件夹。并把一些字体文件放在那里。

我在 css 文件中使用这些文件,如下所示:

@font-face {
font-family: 'B-Yekan';
src: url(../Content/fonts/BYekan.eot) !important;
src: url(../Content/fonts/BYekan.otf), url(../Content/fonts/BYekan.woff) format('woff'), url(../Content/fonts/BYekan.ttf) format('truetype'), url(../Content/fonts/BYekan.svg#VitaminRegular) format('svg');
font-weight: normal;
font-style: normal;
}

但是当网站加载时,我在浏览器的控制台中收到一些内部服务器错误,如下所示:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
http://localhost:30321/OrchardLocal/Themes/Eshoper/Content/fonts/BYekan.woff

可能是什么原因造成的?

您可能需要检查以下内容:

  1. 在 web.config 文件中注册您的字体 mime 类型,如下所示:
<system.webServer>
    <staticContent>
        <remove fileExtension=".woff" />
        <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
    </staticContent>
</system.webServer>

必须在 Orchard.Web/web.config 上应用此设置。

  1. 检查您的Content 文件夹是否包含 web.config 文件,配置如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
        </staticContent>
        <handlers accessPolicy="Script,Read">
            <!-- For any request to a file exists on disk, return it via native http module. AccessPolicy="Script" above is to allow for a managed 404 page. -->
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
        </handlers>
    </system.webServer>
</configuration>

这个文件会告诉Asp.Net这个文件夹包含静态文件,这个文件会被StaticFileModule处理。