Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to debug Global.asax?

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?

like image 998
Mehdi Avatar asked Dec 25 '09 06:12

Mehdi


People also ask

When should I use global asax?

Global. asax is an optional file which is used to handling higher level application events such as Application_Start, Application_End, Session_Start, Session_End etc. It is also popularly known as ASP.NET Application File. This file resides in the root directory of an ASP.

Is global asax mandatory?

asax is not required by ASP.NET for a website to run. It is, however, very useful for application-level functionality (like unhandled exception logging).

What is difference between web config and global asax?

asax contains code which is executed. Web. config contains configuration settings of web application, for example connection string, included libraries, namespaces, users and groups access permissions to virtual directories, etc.


1 Answers

A simple way to break in Application_Start() is to use the System.Diagnostics.Debugger class. You can force the application to break by inserting System.Diagnostics.Debugger.Break() where you would like the debugger to break.

void Application_Start(object sender, EventArgs e)  {      System.Diagnostics.Debugger.Break();       // ... } 
like image 138
Patrick Lee Scott Avatar answered Sep 18 '22 19:09

Patrick Lee Scott