views:

44

answers:

3

I am using Visual Studio 2005, and running my application from inside it, directly using its development application server.

If I set a breakpoint inside Application_Start and one inside Session_Start, the latter is reached first, and I honestly think it should be the other way around.

Any thoughts?

+4  A: 

by default, the Application_Start event will not be hit again whilst running the application unless the web development server is stopped and restarted.

There's a setting in Visual Studio to force the web development server process to be recycled on each launch. Simply right-click the project file > Web > check Enable Edit and Continue. This forces a recycle of the ASP.Net Web Server process on every debug run.

Russ Cam
A: 

Sorry to say so, but you are wrong. The application starts first, and Application_Start is hit once for the lifetime of the application - after application startup, any sessions may start, typically one per user. See ASP .NET Application Life Cycle and ASP .NET Page Life Cycle on MSDN for reference.

driis
I actually wish I were, but russ got it right: actually, the development server was already up and the application, already deployed.Stopping/Starting the application from inside Visual Studio doesn't rerun the whole application lifecycle.
Rodrigo Gama
A: 

The Application_Start is fired the first time your application is loaded into memory. This should trigger every time the AppPool recycles in IIS. If you're talking about the VS local web dev server, it should take a recompile or a stopping and restarting in order to reach Application_Start.

JustLoren