Font files are not loading with ASP.NET Bundles
Well, I think the problem is with your font location. I'm assuming that the bundled css virtual location /BundleStyles/css
doesn't actually exist. and if your folders structure like below
Content > Font
Content > style
If this is true, then try this
change /BundleStyles/css
to /Content/css
<link href="/Content/css?v=pANk2exqBfQj5bGLJtVBW3Nf2cXFdq5J3hj5dsVW3u01" rel="stylesheet"/>
and reference your font like this
src: url('Fonts/ProximaNova/ProximaNova-Bold.otf')
in this case your font will be loaded relative to the "css" file which is located inside the content folder which also contains the "fonts" folder
If what I assumed is incorrect please show us how you structured your files
I think CssRewriteUrlTransform might be the way to go:
https://msdn.microsoft.com/en-us/library/system.web.optimization.cssrewriteurltransform(v=vs.110).aspx
Used like so:
.Include("~/Content/bootstrap-cosmo.min.css", new CssRewriteUrlTransform())
Worked for me.
Great answer above.
An alternative - if for some reason the above didn't work for you - would be to change how the @font-face src property references the 'Fonts' folder. '../'-ing doesn't work very well for bundling so reference directly from the site root folder instead. Assumung the 'Fonts' folder is one down from the root, change this:
@font-face {
src: url('../Fonts/ProximaNova/ProximaNova-Bold.otf') format('opentype');
}
To this:
@font-face {
src: url('/Fonts/ProximaNova/ProximaNova-Bold.otf') format('opentype');
}
You will retrieve the same results when the site is ran in debug mode too.
I went looking online for this today because I am running into this issue. Here's what worked for me:
- The /bundle/ wasn't actually an issue (I tried this first)
- I changed single quotes to double quotes & the fonts worked - but no idea why, so if someone knows please feel free to elaborate.