Application_Start not being hit in ASP.NET web app

后端 未结 2 986
情深已故
情深已故 2021-01-02 09:10

I\'m trying to debug something in the global.asax.cs file in an ASP.NET web app and have set a breakpoint in the Application_Start() event however that event is not getting

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 09:36

    One easy trick to debug newly written code in the global.asax file is to save the web.config file. Each time the config.file is saved, the application is stopped and started.

    You could find useful information in this blog entry

    Workaround: Debugging Global.aspx.cs Application_Start() with ASP.Net Web Server within Visual Studio

    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. There is a good reason why we do so... 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... 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...

    One of the proposed workarounds:

    You can go to your property pages of your web application and enable Edit & Continue like shown below:

    (from the Visual Web Developer Team Blog)

提交回复
热议问题