{"id":4744,"date":"2007-12-13T14:01:00","date_gmt":"2007-12-13T14:01:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2007\/12\/13\/workaround-debugging-global-aspx-cs-application_start-with-asp-net-web-server-within-visual-studio\/"},"modified":"2007-12-13T14:01:00","modified_gmt":"2007-12-13T14:01:00","slug":"workaround-debugging-global-aspx-cs-application_start-with-asp-net-web-server-within-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/workaround-debugging-global-aspx-cs-application_start-with-asp-net-web-server-within-visual-studio\/","title":{"rendered":"Workaround: Debugging Global.aspx.cs Application_Start() with ASP.Net Web Server within Visual Studio"},"content":{"rendered":"<p><P><FONT size=\"2\">When you add a global.asax file to your &#8220;Web Application Projects (WAPs) like below:<\/FONT><\/P>\n<P><A href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_2.png\"><FONT color=\"#000000\" size=\"2\"><IMG height=\"223\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb.png\" width=\"223\" border=\"0\"><\/FONT><\/A><\/P>\n<P><FONT size=\"2\">and then write code in Application_Start event and try to debug it like below using Visual Studio inbuilt Development Web Server<\/FONT><\/P>\n<P><A href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_4.png\"><FONT color=\"#000000\" size=\"2\"><IMG height=\"285\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb_1.png\" width=\"399\" border=\"0\"><\/FONT><\/A><FONT size=\"2\">&nbsp; <\/FONT><\/P>\n<P><FONT size=\"2\">Then during your first debug the breakpoint is hit but during your subsequent debug runs the breakpoint is not hit.<\/FONT><\/P>\n<P><FONT size=\"2\">The reason behind this is that we do not kill the ASP.Net Web Server process after your every debug run and hence Application_Start() is not fired every time.&nbsp; There is a good reason why we do so&#8230;&nbsp; Starting ASP.Net Web Server process is an expensive task and in most of the scenarios recycling this process after every debug would adversely impact your performance&#8230;&nbsp; If you do not want to debug your Application_Start() method then probably you do not need to have the process restart and save performance most of the time&#8230;&nbsp; <\/FONT><\/P>\n<P><FONT size=\"2\">However if you would like to have the breakpoint hit you have few easy workarounds&#8230; One of the workaround is that you stop the web server from your system tray as in the figure below:<\/FONT><\/P>\n<P><A href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_6.png\"><FONT color=\"#000000\" size=\"2\"><IMG height=\"143\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb_2.png\" width=\"243\" border=\"0\"><\/FONT><\/A><FONT size=\"2\"> <\/FONT><\/P>\n<P><FONT size=\"2\">Alternatively you can go to your property pages of your web application and enable Edit &amp; Continue like shown below:<\/FONT><\/P>\n<P><A href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_8.png\"><FONT color=\"#000000\" size=\"2\"><IMG height=\"355\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb_3.png\" width=\"276\" border=\"0\"><\/FONT><\/A><FONT size=\"2\"> <\/FONT><\/P>\n<P><FONT size=\"2\">When you choose Edit and Continue then we recycle the ASP.Net Web Server process on every debug run (it is needed for the Edit &amp; Continue functionality to work)&#8230;&nbsp; This way although you will see very marginal degrade in your performance you will still be able to debug your Application_Start() methods&#8230;<\/FONT><\/P>\n<P><FONT size=\"2\">Hope this helps&#8230;<\/FONT><\/P>\n<P><FONT size=\"2\">&#8211; Vishal R. Joshi | Program Manager | Visual Web Developer Team<\/FONT><\/P>\n<DIV class=\"wlWriterSmartContent\" id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a55b40d8-f4ec-404b-b6eb-fcd4c9c1e8ea\">Technorati Tags: <A href=\"http:\/\/technorati.com\/tags\/Visual%20Studio\" rel=\"tag\">Visual Studio<\/A>,<A href=\"http:\/\/technorati.com\/tags\/Debugging\" rel=\"tag\">Debugging<\/A>,<A href=\"http:\/\/technorati.com\/tags\/ASP.Net%20Development%20Server\" rel=\"tag\">ASP.Net Development Server<\/A>,<A href=\"http:\/\/technorati.com\/tags\/ASP.Net\" rel=\"tag\">ASP.Net<\/A><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you add a global.asax file to your &#8220;Web Application Projects (WAPs) like below: and then write code in Application_Start event and try to debug it like below using Visual Studio inbuilt Development Web Server &nbsp; Then during your first debug the breakpoint is hit but during your subsequent debug runs the breakpoint is not [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[4,31,322,7262,7272,7284,147,7267,7268,7269],"class_list":["post-4744","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-net","tag-asp-net","tag-debugging","tag-development","tag-tips-and-tricks","tag-vishal-r-joshi","tag-visual-studio","tag-vwd","tag-web","tag-web-2-0"],"acf":[],"blog_post_summary":"<p>When you add a global.asax file to your &#8220;Web Application Projects (WAPs) like below: and then write code in Application_Start event and try to debug it like below using Visual Studio inbuilt Development Web Server &nbsp; Then during your first debug the breakpoint is hit but during your subsequent debug runs the breakpoint is not [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=4744"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4744\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=4744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=4744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=4744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}