Reputation: 1875
I need to restart my mvc4 web application programmatically. But System.Web.HttpRuntime.UnloadAppDomain() doesn't work.
What is the best way to restart asp.net mvc application? Please mind that changing web.config content or folder names doesn't solve my problem.
Upvotes: 4
Views: 4667
Reputation: 3421
this code work for me. just call it to reload application.
System.Web.HttpRuntime.UnloadAppDomain();
This method will just unload our application. If you just put this method in an ASP.NET web button you are totally done. So when will our application reloaded? Actually if you click your button it will first launch our method and unload application. Further on the web page we are on at that moment will be reloaded as well, because we just clicked a button and the web page should refresh. After launching our method the page refresh process will cause our application to reload as well.
Upvotes: 12
Reputation: 17182
EDIT - After looking at comment on OutputCache in the question, You can invalidate OutputCache programmatically, Check this out
If still you want to Restart IIS or AppPool then you can follow these resources -
Upvotes: 1