Stop execution of ASP.NET application

安稳与你 提交于 2019-12-10 18:26:14

问题


In my Application_Start() method, how can I stop the execution of the ASP.NET application when certain conditions are not met?

Throwing an exception doesn't appear to work.


回答1:


i don't think that's possible; even if you could 'abort' the startup, the next attempt to access a URL from the site would try to start it again

perhaps a static variable could be used to signal go/no-go, and begin_request could redirect to a placeholder page instead?




回答2:


There seems to be a COM API that you can use for IIS administration. I think I'd try Environment.Exit() first, though.




回答3:


Do something that throws an unhandled error. Maybe throwing an Exception would be enough.



来源:https://stackoverflow.com/questions/380043/stop-execution-of-asp-net-application

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