Url Rewriting Breaks ASP.NET 2.0 Themes - HttpContext.ReWritePath - Screws Up Link to StyleSheet

I was neck deep into ASP.NET 2.0 Themes and Url Rewriting today when I came across the fact that Url Rewriting breaks your ASP.NET 2.0 Themes by changing the base file path looked at by the client and screwing up the relative URL to your stylesheets. Actually, I expected this to happen, but I didn't think the fix was going to be so simple.

Much thanks goes to Fabrice who I remembered blogged about this problem with Url Rewriting and ASP.NET 2.0 Themes the other day.

Turns out this problem with Url Rewriting and ASP.NET 2.0 Themes was reported to Microsoft and they created a new boolean parameter for HttpContext.RewritePath, called rebaseClientPath, that allows you to specify whether or not you want the virtual path reset when doing Url Rewriting.

public void RewritePath (string path, bool rebaseClientPath)

By default, rebaseClientPath is set to true, which is why the links to the stylesheets are broken. If you are doing Url Rewriting with ASP.NET 2.0 Themes and having problems with your stylesheets, change your code to set rebaseClientPath to false and it may fix your problem.

http://davidhayden.com/blog/dave/archive/2006/01/14/2693.aspx

search this blog (most likely not here)