Saturday, February 06, 2010

Boilerplate HTTPHandler

I have a couple of aspx pages (that I inherited from a project) that are never really used to render HTML content to an end user and instead are used to receive a HTTP post message and process the contents. Granted that I could use a web-service to process the messages being sent – but that would involve changing the clients that send the post messages and those are out of my control.

Today I came across the IHttpHandler and this will work perfectly for me:
1. Clients can continue sending their post messages
2. I can re-architect the pages to be HttpHandlers and save on a lot of extra handling that the normal aspx page would have to do.

IHttpHandler defines the contract that ASP.NET implements to synchronously process HTTP Web requests using custom HTTP handlers

And here is a base class HttpHandler by Phil Hack that I think will be useful for just such a project: http://haacked.com/archive/2005/03/17/AnAbstractBoilerplateHttpHandler.aspx

Phil Hacks HttpHandler base class is based on a Scott Hanselman base-class: http://www.hanselman.com/blog/PermaLink,guid,5c59d662-b250-4eb2-96e4-f274295bd52e.aspx

More Info: Code-behind for HTTPHandlers: http://aspnetresources.com/blog/httphandler_code_behind.aspx

No comments: