Handling Application.Start via Custom HTTP Module

C

Cramer

Using ASP.NET 3.5: Can a custom HTTP Module be used to register for the
Application_Start event? Or _must_ I use Global.asax to work with
Application.Start?

I understand that I can use a custom HTTP Module to register for other
pipeline events (like Application.BeginRequest), but I was told that the
only place that I can set up an event handler for Application.Start is in
Global.asax.

My preference would be to register an HTTP Module in Web.config that, upon
its initialization, has logic that determines if Application.Start needs to
be handled, and if so, which class and method (that I load dynamically into
the application's default AppDomain) is to handle Application.Start.

So, ideally, things would go like this (please tell me if you see any
problems with doing things this way):
1. When the application is first started, a custom HTTP module is loaded
(per Web.config).

2. That custom HTTP module has logic that determines if Application.Start is
to be handled.

3. If runtime conditions dictate that Application.Start is to be handled,
then the HTTP module proceeds to load the correct assembly, instantiate the
correct class, and register the correct Application.Start event handling
method with the Application.Start event.

4. The Application.Start event is then raised, thereby invoking the event
handling method wired up in step 3 above.

For the above to work, I would have to rely on somethig that I don't quite
understand... and that is the sequence of activities that take place when an
ASP.NET application is started: in particular, I would need to be able to
count on my custom HTTP module being loaded *before* Application.Start is
raised. Can I count on that sequence?

Your feedback and comments are appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top