Search code examples
cssorchardcms

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


I use Orchard CMS 1.10.1. I have created a font folder inside Content folder in my custom theme. And put some font files in there.

And I use these files in a css file like this:

@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;
}

But when website loads, I get some Internal server errors in browser's console like this:

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

What might be causing this?


Solution

  • You might need to check the following:

    1. register your fonts mime types in web.config file, like this:
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
        </staticContent>
    </system.webServer>
    

    This settings must be applied on Orchard.Web/web.config.

    1. Check youContent folder if it contains a web.config file, with this configuration:
    <?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>
    

    This file will tell Asp.Net that this folder contains static files, and this files will be handled by StaticFileModule.