I encountered some issue while trying to integrate some third party controls to BlogEngine, the culprit is the CssHandler in my case, fortunately, the walkaround is pretty simple. Below is the issue description and the walkaround to share...
Issue Description: Build a control includes CSS files as webresource, while BlogEngine renders the css file, it triggers CssHandler by reading the url css.axd?name=[webresource url].
Walk Around: Move the CSS files out of the control, instead putting them in BlogEngine project directly, and have them referred in the actual page that needs the resource. Not to use this.Page.ClientScript.GetWebResourceUrl(this.GetType(), css), otherwise, you will need to handle the request in CssHandler like below...
......
// Check if a .css file was requested, exclude the check for web resource
if (!fileName.EndsWith("css", StringComparison.OrdinalIgnoreCase) && fileName.IndexOf("webresource.axd",StringComparison.CurrentCultureIgnoreCase) < 0)
throw new System.Security.SecurityException("Invalid CSS file extension");
if (fileName.IndexOf("webresource.axd", StringComparison.CurrentCultureIgnoreCase) > 0)
{
css = RetrieveRemoteCss(fileName);
}
else
{
// In cache?
if (context.Cache[context.Request.RawUrl] == null)
{
// Not found in cache, let's load it up
if (fileName.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{
css = RetrieveRemoteCss(fileName);
}
else
{
css = RetrieveLocalCss(fileName);
}
}
else
{
// Found in cache
css = (string)context.Cache[context.Request.RawUrl];
}
}
.......
This is not a ideal solution, but as a walkaround, it works.