Rodrigo Gama
Rodrigo Gama

Reputation: 1122

Asp.NET Global.asax - application lifecycle

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?

Upvotes: 2

Views: 9829

Answers (3)

Russ Cam
Russ Cam

Reputation: 125538

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.

Upvotes: 9

driis
driis

Reputation: 164341

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.

Upvotes: 3

JustLoren
JustLoren

Reputation: 3234

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.

Upvotes: 1

Related Questions