开发者

In ASP.NET, can an HTTPHandler skip the Global.asax.cs Application_BeginRequest Handler?

I'm running und开发者_如何学运维er 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!


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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜