Import Stylesheet causing exceptions

Celero Solutions asked on April 28, 2014 14:26

Hi, We have an import directive set on the main stylesheet: @import url('/webfonts/MyFontsWebfontsKit.css') @charset "utf-8";

For whatever reason, when certain pages are visited, exceptions are being generated and are viewable in the event log. The error is /CMSPages/url('http:/www.website.com/webfonts/MyFontsWebfontsKit.css')@charset "utf-8". Again, this is occurring with about 5 pages. Has anyone ever had this issue before?

Recent Answers


Brenden Kehren answered on April 28, 2014 14:51

Your @charset can only appear once in a stylesheet and when you import the other, now its there twice. Secondly, your @charset and @import statements need to be on the same line if in the same file. I typically take my font stylesheet css and place it in the top of the main stylesheet, makes it a bit easier to work with. Other option would be to create a new stylesheet in the Site Manager and use the Head HTML webpart to place it on your page. I use this method quite a bit as well too.

0 votesVote for this answer Mark as a Correct answer

Celero Solutions answered on April 28, 2014 16:13

Hi Brenden, I checked the main stylsheet and the @charset is set only once. I moved the import and charset onto one line so that they appear like this: @import url('/webfonts/MyFontsWebfontsKit.css')@charset "utf-8"; It was already at the top of the stylesheet. The odd thing is, the exception is only appearing for certain pages. Why not all pages? The other thing is, I checked our dev site and there are no exceptions there even though it is importing the same stylesheet and is set up the same way.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 28, 2014 16:48

I read one time @charset has to be first. My guess is IIS is automatically serving that font css file up because its in the App_Themes directory. This is the reason I add it as a new stylesheet in the Site Manager. You can easily manage it and version control it and control when it gets added to your pages. Take a look at the few pages you're having problems with and see if that stylesheet is in your source on that page.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.