'How to restart asp.net core published app
I have a problem with changing appsettings.json on the asp.net core application that is published on the host, I want to change the settings and restart the app to use new settings. but I don't know how to restart the app.
in ASP.NET webforms, we change the web.config, and its forces the application to restart. but in asp.net core, it's not work.
how to restart the application when appsettings.json changes?
Solution 1:[1]
- You can still use
web.configin IIS with ASP.NET Core... sort-of:- Even though ASP.NET Core doesn't use
web.configfiles anymore, IIS still usesweb.configto set IIS web-server settings (in<system.webServer>). - So adding even a stub
web.configfile, then making some insignificant change to it (I don't thinktouch web.configwill work, though) then IIS will restart the website's application based in that virtual-dir or application-scope.
- Even though ASP.NET Core doesn't use
Solution 2:[2]
You can stop the app, and then reloading the page manually will run the app again.
public class StopApp
{
private readonly IHostApplicationLifetime _host;
public StopApp(IHostApplicationLifetime host)
{
_host = host;
}
public class Stop()
{
_host.StopApplication();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dai |
| Solution 2 | LazZiya |
