I'm in Azure, CORS, and WOFF hell - wordpress

I have a WordPress site running on Azure Websites and I'm trying to get the Azure CDN setup. I have the endpoint and storage configured. All of the files have been uploaded.
My issue is with WOFF and TTF files. Chrome is reporting a 200 OK status, but the file size is 0KB. The Console in Firebug reveals the CORS issue. The font is definitely not working as I'm just getting a block icon where these fonts are used.
I have the Azure CORS rules setup. Here's a snapshot...
Allowed origins: http://fonts.gstatic.com, http://cdn.devsoftsolutions.com
Allowed methods: Get, Head, Put
Allowed headers: x-ms-*
Exposed headers: x-ms-*
Max age (seconds): 200
Here's my web.config settings...
<staticContent>
<remove fileExtension="svg" />
<remove fileExtension="eot" />
<remove fileExtension="woff" />
<remove fileExtension="ttf" />
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".woff" mimeType="application/octet-stream" />
<mimeMap fileExtension=".ttf" mimeType="application/font-ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/vnd.ms-fontobject" />
</staticContent>
The site that I'm trying to get this working on is http://dev.devsoftsolutions.com

I wonder how do you expect WOFF and TTF to be working when you define more than one mimeMap per extension?! How do you expect IIS to handle this?! You shall only define exactly one mime map per extension (IIS takes the last defined!). Your correct configuration shall look like this:
<staticContent>
<remove fileExtension="svg" />
<remove fileExtension="eot" />
<remove fileExtension="woff" />
<remove fileExtension="ttf" />
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".ttf" mimeType="application/vnd.ms-fontobject" />
</staticContent>
And you can always consult IANA on which are the correct mime types. On this demo site you shall be able to see a briefcase icon from WOFF file. You can use browser debugging tools or Fiddler to see that the WOFF is correctly transferred and interpreted by the browser.
Oh, and another note - you do not need to enable CORS for Google's fonts! CORS is only required when you want to SEND data using JavaScript or make AJAX calls! Google fonts come to your site with simple script src and CSS #url() for which CORS is not required.

Related

FontAwesome error in IIS

I get the following error in my ASP.Net MVC page when running in IIS
downloadable font: download failed (font-family: "FontAwesome" style:normal weight:normal stretch:normal src index:1): status=2147746065 source: http://localhost/MyApp/fonts/fontawesome-webfont.woff?v=4.1.01 sharedStyle:1:126778
The same page running locally, everything works fine. All files are deployed
and the path to FA is C:\inetpub\wwwroot\MyApp\Content\Template\font-awesome-4.1.0
I tried all solutions from Why font-awesome works on localhost but not on web ? and ASP.NET MVC4 Bundling with Twitter Bootstrap
UPDATE:
I added fileExtensions to system.webServer as suggested by Shyju, but it did not change the problem.
Is it possible that there is a problem with bundling? I use it in the following way:
public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle sharedStyleBundle = new StyleBundle("~/bundles/sharedStyle");
sharedStyleBundle.Include("~/Content/Template/font-awesome-4.1.0/css/font-awesome.css");
...
bundles.Add(sharedStyleBundle);
...
}
IIS does not know how to serve these new types of files. We should explicitly tell that these are good file types.
Add this section to your web.config under <system.webServer> section. That should fix it.
<staticContent>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
Sometimes, If it is already added ,you need to remove it and re-add it to avoid possible conflicts/errors.
<staticContent>
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
I had to change the bundling as follows:
public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle sharedStyleBundle =
new StyleBundle("~/Content/Template/font-awesome-4.1.0/css/bundle");
sharedStyleBundle
.Include("~/Content/Template/font-awesome-4.1.0/css/font-awesome.css");
bundles.Add(sharedStyleBundle);
...
}
It seems to be important, that the key for the bundle has the same structure as the bundle path itself.

web.config error - webm, ttf, ogv

I am having issues adding extensions to the web.config file.
I made it because it was returning webm files with a 404 error despite being on there.
when I upload this to the root folder of my godaddy hosted server, it gives me an error "The page cannot be displayed because an internal server error has occurred."
Is it returning an error because it is poorly formatted or why else?
thanks
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<remove fileExtension=".ttf"/>
<remove fileExtension=".eot"/>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="pplication/x-font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>
</system.webServer>
</configuration>

SVG still not appearing after adding mime type

I am trying to display an svg image.
When I display the svg image with the below code is does not display.
<img src="/img/logo.svg" alt="Logo">
I also tried this syntax, but then it downloads instead of displaying.
<embed type="image/svg+xml" src="/img/logo.svg" />
I have already set the mime type to image/svg+xml in web.config.
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".svgz" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
</staticContent>
It appears to be seeing the file type as application/octet-stream even though I have defined it at image/svg+xml. I am running and ASP.NET site with IIS 7.
I recently ran into this problem and my web.config syntax for the mime type looks slightly different to yours.
This:
<staticContent>
<mimeMap fileExtension="svg" mimeType="image/svg+xml" />
</staticContent>
is all I added and it fixed the problem. Hope it helps!
Add the following to your web config:
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<handlers>
<add name="SVG Handler" path="*.svg" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
If you have access to .htaccess file (at the root), add this line of code:
AddType image/svg+xml .svg .svgz

MP4 not played in IE10

I am using in my .aspx file the following code:
<video controls="controls" >
<source src="movie.mp4" type='video/mp4'>
<source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' />
<source src="movie.webm" type='video/webm'>
</video>
in web.config I placed:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
</staticContent>
</system.webServer>
...
In FF22 the mp4 movie is displayed in the correct way, but in IE10 I get the error 'Invalid source'. If I create a basic HTML file with the same 'video' tag, I can view the video also in IE10 (with file: protocol). For some reason the filetype in IE10 for the MP4 file is always 'application/octet-stream', instead of 'video/mp4' as specified in the web.config.
Any ideas why this happens?
sApparently you can't override this in a location tag or even in your web.config like so:
<staticContent>
<mimeMap fileExtension="woff" mimeType="application/x-font-woff" />
<remove fileExtension="ogg"/>
<remove fileExtension="mp4"/>
<remove fileExtension="webm"/>
<mimeMap fileExtension="ogg" mimeType="video/ogg" />
<mimeMap fileExtension="webm" mimeType="video/webm" />
<mimeMap fileExtension="mp4" mimeType="video/mp4" />
</staticContent>
Instead, I had to add .mp4 under mime types in the GUI (this doesn't appear to have altered web.config at all) as a local definition:
Confirmed with fiddler, the .mp4 is now served with a content type of video/mp4 (even though the staticContent tag was defined previously)

CSS-defined font not found [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
#font-face not working on a client site?
I have the following font files in this folder structure in my ASP.Net MVC web app:
-[root]
|-- Public
||--fonts
|||--NuvoWeb-Medi.eot
|||--NuvoWeb-Medi.woff
In my CSS file I have the following font declaration:
#font-face
{
font-family: NuvoWeb;
src: url(/Public/fonts/NuvoWeb-Medi.eot);
}
#font-face
{
font-family: NuvoWeb;
src: url(/Public/fonts/NuvoWeb-Medi.woff) format('woff');
}
However, when I run the app, Firebug returns the following error:
"NetworkError: 404 Not Found -
http://localhost:60194/Public/fonts/NuvoWeb-Medi.woff"
Please advise as to what I am missing in order to get this to work.
Found the solution here...
The problem is that IIS doesn’t know how to serve these new files unless we tell it how. This can be easily done in the web.config’s in the web.config’s <system.webServer> section by adding the following snippet:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
<mimeMap fileExtension=".spx" mimeType="audio/ogg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
Note that some of these extensions may already be handled in IIS (for me, .svg was fine). You either need to remove those maps from this section, or include additional <remove> lines like the one for .eot.
Register the MIME type in web.config as follows:
<system.webServer>
<staticContent>
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
</staticContent>
</system.webServer>
This solves the problem.
public folder(css here) ---> font folder (font here -NuvoWeb-Medi.eot)
#font-face
{
font-family: 'NuvoWeb';
src: url(fonts/NuvoWeb-Medi.eot);
}
you were missed quotation symbol font-family: 'NuvoWeb';

Resources