Using ASP.NET 3.5: Can a custom HTTP Module be used to register for the
Application_Sta rt event? Or _must_ I use Global.asax to work with
Application.Sta rt?
I understand that I can use a custom HTTP Module to register for other
pipeline events (like Application.Beg inRequest), but I was told that the
only place that I can set up an event handler for Application.Sta rt 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.Sta rt 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.Sta rt.
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.Sta rt is
to be handled.
3. If runtime conditions dictate that Application.Sta rt is to be handled,
then the HTTP module proceeds to load the correct assembly, instantiate the
correct class, and register the correct Application.Sta rt event handling
method with the Application.Sta rt event.
4. The Application.Sta rt 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.Sta rt is
raised. Can I count on that sequence?
Your feedback and comments are appreciated!
Application_Sta rt event? Or _must_ I use Global.asax to work with
Application.Sta rt?
I understand that I can use a custom HTTP Module to register for other
pipeline events (like Application.Beg inRequest), but I was told that the
only place that I can set up an event handler for Application.Sta rt 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.Sta rt 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.Sta rt.
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.Sta rt is
to be handled.
3. If runtime conditions dictate that Application.Sta rt is to be handled,
then the HTTP module proceeds to load the correct assembly, instantiate the
correct class, and register the correct Application.Sta rt event handling
method with the Application.Sta rt event.
4. The Application.Sta rt 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.Sta rt is
raised. Can I count on that sequence?
Your feedback and comments are appreciated!