Global.asax Events and Debugging

This is something I came across recently when trying to debug some events that were executed in Global.asax.

I was updating a database at Application_Startup but it didn't seem to be firing. I was running in Visual Studio locally on my laptop, I repeatedly executed my application in debug mode and waited for the database update to fire. I even tried SQL Profiler to detect when the database was being updated.

But no data was being written to my database. Straaaange!

Alas, not so strange when you think about debug mode. Visual Studio uses it's on "web server" in debug mode. However, it doesn't close the web server between instances of debug mode. That means, the web server continues to run from the time you initiate debug mode until you close Visual Studio (or you close the web server).

When I realised that, I realised that the Application_Startup event wasn't firing. Because the application was already running. When I closed the web server and initialised debug mode again, voila. My database updates were happening again.

Just a little thing but there maybe more of you who have a similar problem. Let me know your thoughts.

Til next time ....

zp8497586rq