views:

370

answers:

1

I'm running under IIS 6.

I've got an HttpHandler that handles requests for a particular file extension (let's call the extension .foo).

My Application_BeginRequest handler in Global.asax.cs performs an operation that I don't want to happen in response to .foo requests.

I know that within the Application_BeginRequest handler I could conditionally execute the operation based on HttpContext.Current.Path (or something like that) but I would prefer not to muddy the Global.asax.cs file's logic with details it shouldn't need to know about.

I would prefer to have the .foo file's HttpHandler always skip the Application_BeginRequest handler.

Thanks!

+2  A: 

I don't think this is possible. The Application_BeginRequest event is fired before IIS even knows which HTTPHandler is going to process the request.

The Global.asax construct is a bit outmoded. What you are essentially getting is the same thing as a custom HttpModule... and by definition, all Requests must pass through all the registered modules. That being the case, I think it's fine to add logic to the BeginRequest handler to only execute conditionally. But maybe what you really want to do is move this logic to a custom HttpModule? Or multiple modules... then the code and logic is less "muddy".

Bryan
Thank you Bryan! It sounds like I need to read up on the order of events for a request. :)
Tim Stewart