Click here to Skip to main content
12,552,478 members (26,725 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as



Breakpoint in global.asax is never reached by debugger in VS

, 3 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Yesterday at work, I came across the situation where I had inserted a breakpoint to debug some code inside my global.asax file in a web application, but the VS debugger never reaches it. The first indication of trouble came when … Continue reading →

Yesterday at work, I came across the situation where I had inserted a breakpoint to debug some code inside my global.asax file in a web application, but the VS debugger never reaches it.

The first indication of trouble came when some data values loaded during application start never changed, even after I manually changed the database records. After a clean/build in VS, the values changed to what I expected, and debugging the global.asax file became possible. But the next debug run show the values never change, and the code in global.asax is never reached. The initial thought that came to mind was that global.asax, where the application start events are fired, was acting very funny.

Reading up on this issue on the net brought up the overlooked fact that Cassini, the lightweight web server distributed with ASP.NET, does not close down after it has initially started, in order to increase performance the next time the application is run. This means that the application start events do not fire until the next time the web server process is restarted.

In essence, the problem I was facing was that each time I try to debug my global.asax file, if the application start events have already been fired and loaded, the code in the global.asax is skipped. Why it works when I do a clean/build is that Cassini has to restart after each build. The direct workaround this is to go to the system tray, right-click on the Cassini icon and select stop. Now the debugger can reach breakpoints inside global.asax next time the application is run.

Rather than manually killing the process each time you stop debugging, you can use the edit and continue option in VS. Enabling edit and continue does not kill the Cassini process, but restarts it each time you debug the application. The option can be enabled in VS 2010 by selecting ‘debug’ in menu bar, and then option and settings:

If you are using IIS (as I was) to debug the web application, killing the Cassini process will not help. In this case, you have to start the IIS manager, and check which application pool your web application has been assigned to. Once you know the application pool, right clicking it and selecting advanced settings brings up the window shown below:

In this case, the idle time-out sets the time limit for the worker process to shut down. Changing the time to zero would disable the setting, and each time requests come in, the web application would load its application settings anew. If you do not want to change the setting, the alternative would be to restart the application pool by right clicking it, selecting stop, and again selecting start. But you would have to do this after each debug run, so disabling it by entering zero for the idle time-out would be the better option.

This in essence, is the activities you have to go through in order to debug global.asax files. I welcome any suggestions and ideas on the readers’ part.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mark Vinod Sinnathamby
Technical Lead Exilesoft
Sri Lanka Sri Lanka
I am a software craftsman who is passionate about software architecture/ecosystems, and an ardent advocate of shipping high quality software that enhances user experience and provides business value. My technical experience extensively covers the Microsoft .NET stack, C/C++ development, and web application design/development.

In my current tenure, I work as a technical lead at Exilesoft, a hardcore software engineering firm that provides solutions, services, and consultancy, to a global client base in various industrial and technology domains. Prior to working at Exilesoft, I have worked as a developer for a software product engineering company, a senior engineer for a startup in the design and manufacturing space, and also as an ERP/technical consultant for a Fortune 500 company.

My current areas of research and interest revolve around enterprise architecture/EAI, machine learning, NoSQL databases, big data, and predictive analytics. I blog at on various topics related to software engineering, artificial intelligence, data/computer science, and mathematics. Feel free to email or message me anytime and strike up a conversation.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161021.1 | Last Updated 4 Sep 2010
Article Copyright 2010 by Mark Vinod Sinnathamby
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid