azure webrole Global.Application_Start is never called

2.5k views Asked by At

I created a simple ASP.NET project and then added cloud deployment descriptor using Visual Studio. Once I do that, Application_Start() method in global.asax file never gets called. In my project, I do lot of initialization such as loading web.config file, loading connection strings, initiailizing cache, etc. I can not put all of them into WebRole.OnStart() method.

Is there any special configuration required to have Application_Start() method in Global class invoked?

Thanks, Prasanna

1

There are 1 answers

1
AvkashChauhan On BEST ANSWER

As SMARX stated Applicaton_start() is always called however with your Web Role if you have full IIS role then VS2010 debugger does not hit Application_start(). I am writing the detail below on how you can hit BP at Application_Start() in Global.asax.cs:

First you can write Debugger.Break() code in your Application_Start() as below: enter image description here

Now please open your Role Properties > Web and select

  1. Use Visual Studio Development Server settings (I have chosen as shown in image below)
  2. Use Local IIS Web Server

enter image description here

Now debug your application and you will see a message as below to debug W3WP.EXE process

enter image description here

Select Debug option above and then you will see BS JIT Debugger Windows as below:

enter image description here

Once you accept VS JIT debugger launch process, you will see the PB hit in your Applicaton_start() as below:

enter image description here

That's it!!