Wednesday, October 26, 2005

Asp.Net 2.0 Themes und URL-Rewriting

this is a well know problem with the relativ path's. Themes are using by default relativ Paths. the workaround is to use the follwoing method:

the reg-ex which is used here: ""

Notice: its just match css-links like in the sample!!!!

public override void Write(byte[] buffer, int offset, int count){string strBuffer = System.Text.UTF8Encoding.UTF8.GetString(buffer, offset, count);
// ---------------------------------// Wait for the closing tag// ---------------------------------Regex eof = new Regex("", RegexOptions.IgnoreCase);
if (!eof.IsMatch(strBuffer)){responseHtml.Append(strBuffer);}else{responseHtml.Append(strBuffer);
string finalHtml = responseHtml.ToString();Regex re = null;
// Css-Files auf die absolute Client-URL mappenre = new Regex("", RegexOptions.IgnoreCase);finalHtml = re.Replace (finalHtml, new MatchEvaluator (CssMatch));
// Write the formatted HTML backbyte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(finalHtml);
responseStream.Write(data, 0, data.Length);}
}
private string CssMatch(Match m){return m.ToString().Replace(m.Groups[1].Value, ConfigurationManager.AppSettings["ApplicationRoot"] + m.Groups[1].Value);}

Source: http://blogs.dotnetgerman.com/thomas/PermaLink,guid,f211331c-b175-4a25-8958-ece6bc6d364a.aspx

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge