How to disable CssHandler ?

Sep 1, 2008 at 12:55 PM
Hi all,

I'm messing around with the css and themes and because it now caches the css file it doesn't immediately reflect changes in the css.

In CssHandler.asmx Changing the line :


private const bool DO_GZIP = true;




private const bool DO_GZIP = false;

Seems to help a bit... but the thing still seems to cache the css. Is there any way of disabling the handler temporarily so you can make changes to the css file and see immediate results?

Thanks in advance!


Sep 1, 2008 at 2:43 PM
Ok that was quite easy... In the file App_Code/BasePage.cs simply change the cssPath variable like so:


//string cssPath = CSS_PREFIX + "CssHandler.ashx?t=" + themeName



// + "&f=" + HttpUtility.UrlEncode(themeCssNames.TrimEnd(','))



// + "&v=" + CSS_VERSION;



string cssPath = "/App_Themes/GreenBlue/mystyles.css";

If you want the handler back - simply reverse the process

Hope this helps somebody :)


Nov 5, 2009 at 6:34 PM

Yes !! Me !! Thanks spacecowboy :P !!

Mar 22, 2010 at 2:28 PM

Another way is to change the CssHandler class. I changed this line:

if (!this.WriteFromCache(context, themeName, version, isCompressed)) (line 32 for me)

to this:

if (!this.WriteFromCache(context, themeName, version, isCompressed && 1 == 2))

thus forcing this to always evaluate to false, and thereby never use a cached css. It would best be implemented as a conditional build (never cache in debug mode, always cache in production), but I haven't looked into that yet. :-)

- Niklas