views:

647

answers:

2

Hi All,

I have an HttpApplication (Global.asax) in my web application, I use this to catch and log unhandled Exceptions and to setup WebFormURLRouting. This all works, however I want to move this code into my Application Framework, (ie not in Global.asax.cs)

I have just tried to create an HttpApplication class in the framework but it seems I cant override the Events? Anyway I believe I can use an HttpModule instead to use consume these events, does this:

1) Eliminate the need for the Global.asax completely?

2) How does this effect scaling up, ie eventually running the application on a web farm

3) I have HttpHandlers to handle other things like File Uploading and File downloading, is there a limit to how many HttpModule/HttpHandlers should be used or should these be combined somehow to reduce overhead?

Any comments appreciated

+1  A: 

Listening to the events you know from Global.asax, in an HTTP module, is as simple as hooking up to the events of the HttpApplication instance in the module's Init method. You cannot override the methods of the HttpApplication, you should listen to it's events.

As for your other questions: 1) Yes, in many of my web projects, we do not use a Global.asax

2) This does not really affect up-scaling. For each web server in the farm, you would need to have your HTTPModule hooked up correctly. But since this is done in web.config, it should be there already.

3) Short answer: No. For httphandlers, they are selected and run based on the incoming http request file extension and/or path and HTTP method. You would really need a lot of these before the selection of a specific handler becomes a performance issue. For HttpModules, you have the option of running some code at each request, and obviously, if that code takes time to run, it will affect performance. But it will be your code that takes the time, not the fact that it is being run via a http module.

driis
+1  A: 

You can create your Application class in the your Framework and inherit from it in each application. So you will have all your handles in the framework.
The answers:

  1. You can avoid using Application class, but addign the Handlers for that is not a good idea.
  2. Number of handlers does NOT affect scallability in general. BUT IT DOES AFFECT MAINTENABILITY.
  3. Keep number of handlers small because of #2.
Dmytrii Nagirniak