skip to Main Content

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?

2

Answers


    • 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 uses web.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 think touch web.config will work, though) then IIS will restart the website’s application based in that virtual-dir or application-scope.
    Login or Signup to reply.
  1. 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();
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search