Friday, 3 October 2008

HttpHandler in App_Code folder

OK. Using App_Code in .NET websites is typically bad practice - at least, thats my opinion. However, sometimes it is handy to test something quickly in a local site, etc.

I needed to add an HttpHandler to try out a theory today and it took me more than a couple of minutes to figure out how to reference one in App_Code from web.config. I thought I'd repeat the solution here, having found it - to make it easier for the next person.

Working example:

<add verb="*" path="*.css" type="CssHandler, App_Code"/>

The name of my class is "CssHandler" (logically), and because it is in the App_Code folder, that is the assembly name.