Adding CSS file to a master page - illegal characters in path?
-
09-12-2019 - |
Question
I'm making a custom master page with a custom CSS file, being deployed in a feature form VS2010. I'm using the CssRegistation control to add the new CSS, but whenever I try to load a page that uses it, I get an "Illegal characters in path" exception. Which is odd, because there aren't any illegal characters that I can see in the path.
The code I'm using to add the CSS to the page looks like this (from MSDN):
<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/myfolder/mystyle.css %>" After="corev4.css" runat="server"/>
I've check the relevant galleries and the master page is deploying correctly to _layouts/masterpage/mymaster.master, and the CSS is deploying correctly to Style Library/myfolder/mystyle.css.
What have I missed?
Solution 2
I'm an idiot. The error was coming from an old CssRegistration control that I hadn't commented out properly...
OTHER TIPS
Have you tried changing "Style Library" to "Style%20Library"?
According to this blog post, you will have that issue if you are using SharePoint Foundation: http://blogs.msdn.com/b/sharepointdesigner/archive/2010/04/09/working-with-the-sharepoint-theming-engine.aspx. In SPF you need to hard code the URL.