Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

global.asax breakpoint not hit

I have some code in my ASP.NET app in C# that's in the Global.asax.cs code file. In the Application_Start, Session_Start and Application_Begin Request I have set some breakpoints. However none of these are ever hit. I'm working on my local machine with VS8.

Here's what I've tried:

  • Stopped the ASP Dev Server
  • Deleted all ASP.NET Temporary files
  • Created new Global.asax
  • Closing VS and opening back up
  • Clean and Rebuild project

Upon trying my after these, the breakpoints will not hit.

Any ideas why this might be?

like image 972
user259286 Avatar asked Oct 05 '11 11:10

user259286


2 Answers

I've run into this same problem. I'm assuming you are using your local IIS instead of the VS Development Server. If this is the case, you won't be able to debug/Step through this code in the Global.asax.cs file because by the time the debugger has attached, this code has already executed in IIS. However, if you use the Dev server, you have the ability to get to this code as the debugger will already be attached.

So, Change the server in your project properties to use the Visual Studio Development Server.

This can be found by right clicking your project within Visual Studio > Project Properties > Web tab > Use Visual Studio Development Server.

like image 101
Jeff Reddy Avatar answered Sep 18 '22 10:09

Jeff Reddy


What helped me was to add:

System.Diagnostics.Debugger.Break(); to that Application_Start() method.

like image 32
Ofiris Avatar answered Sep 20 '22 10:09

Ofiris