Jan
10
2007
Master pages, themes and url rewriting
Posted by admin under
ASP.NET 2.0
When you are using themes, the ASP.NET engine will automatically create <link href="App_Themes/themename/css/yourcss.css" type="text/css" rel="stylesheet" /> tags for each css file placed in (or under) the active theme directory.
If you at the same time are using url rewriting you will probably end up with no css bening found - cause the link href'' statement uses a relative path. So a request to
/yoursite/category_12/article12.aspx
which you rewrite to
/yoursite/article.aspx?artid=12&cat=12
will of course try to find the css at
/yoursite/category_12/themes/css/....
instead of
/yoursite/themes/css/....
The simpkle solution is to use the rebaseClientPath flag in RewritePath:
HttpContext.Current.RewritePath(sOldPath,false);
Just a note: the "side effect" is you will now end up with relative paths - such as
<link href="../../../../App_Themes/themename/css/yourcss.css"
i.e a lot of ..\