I can't debug global.asax file!
I have some codes in Application_Start()
method but when I set a break point in the method, it is ignored!
Is this normal?
I can't debug global.asax file!
I have some codes in Application_Start()
method but when I set a break point in the method, it is ignored!
Is this normal?
Yes, it is normal.
Application_Start()
is processed by IIS.But all other methods, for example
Session_Start
, and all others, exceptApplication_Start()
can be debugged normally.Delete the
global.asax
and add a new one. In my solution, there has been aglobal.asax
and aglobal.asax.cs
.All the methods (
Session_Start
,Application_Start
, ...) have been in the bot files, but only the ones in theglobal.asax
have been considered. So, break points and code in the cs don't do anything.Only after recreating the file, the
global.asax.cs
had the appropriate methods and they ran.Another alternative to the accepted
System.Diagnostics.Debugger.Break();
would bewhich shouldn't break the code and should start the debugger even if the service were started with different rights.
Dont expect the Application_Start() function to be called immediately by pressing f5. Application_Start() is invoked only at the time of first request to the application is made. Strange but true.
Application_Start()
is invoked once per AppDomain. If you're not hitting your breakpoint, it means the AppDomain was already created, so do the following: