What happens if an unhandled exception is thrown in Application_Start?

☆樱花仙子☆ 提交于 2019-12-22 01:53:13

问题


... will the Application_Start method be ran again for the next request(s) or not?

Does it depend on ASP.NET version, hosting server version and/or other context?

I am trying to determine if it's a good thing to load critical assemblies there or not. For example data access assemblies which are vital to the functioning of the whole application or not. Failure to load such assembly would make subsequent requests useless.


回答1:


Application_Start will be fired only once for each web application so in your case, the start will not happen again for subsequent requests.

Typically, I prefer to put one time start-up code in the application start within try-catch and if there is an exception then set the global error flag. In each BeginRequest, the flag is checked and if it is set, user is redirected to a custom error page indicating the site is down and please contact the administrator.



来源:https://stackoverflow.com/questions/5876703/what-happens-if-an-unhandled-exception-is-thrown-in-application-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!