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?
CodePudding user response:
- You can still use
web.config
in IIS with ASP.NET Core... sort-of:- Even though ASP.NET Core doesn't use
web.config
files anymore, IIS still usesweb.config
to set IIS web-server settings (in<system.webServer>
). - So adding even a stub
web.config
file, then making some insignificant change to it (I don't thinktouch web.config
will 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
CodePudding user response:
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();
}
}