views:

72

answers:

2

Hi all
I need an interface that can be run firstly when the application start.
We can write some code in Application_Start of global.ascx.
Is there any other method to finish it after some configurations in web.config,i don't wanna write any code in global.ascx
You know,we can implement the Interface 'IHttpModule' to diy each request.
But the interface is not fix to application start.
which one is i wanna? Thanks

A: 

You can use the Init method of your module. It fires more or less around the same time as the Application_Start for the Global.asax.

Darin Dimitrov
that init method will be run each time when meeting remote request.But i only want to run one time.
Edwin Tai
A: 

A HttpModule is something that handles requests, and is not directly related to the lifetime of an application. Even if it's reusable, it may not survive during the whole lifetime of an application. The Global.asax file, on the other hand, becomes a subclass of HttpApplication, which indeed is a class that relates to the startup, shutdown and lifetime of a web application. According to MSDN, Global.asax is the file to put startup and shutdown code.

bzlm
hey,in other word,who knows what load gobal.ascx that can be overloaded.
Edwin Tai
Normally, code that runs *when the HTTP Application starts* is placed in `global.asax`. There is no "overloading" involved - the application itself has just this one entry point, as it were.
bzlm