0

I saw that in asp.net older version, editing configuration cause recycle. (so we implemented our own library for dynamic config to avoid recycling).

Now I'm writing new asp.net core app and I have not seen anywhere that there is recycle, if using built-in configuration (like:

.AddJsonFile("appsettings.json", optional: true, **reloadOnChange: true**)

So, can I use it without expecting any down time?

Community
  • 1
  • 1
arielorvits
  • 5,235
  • 8
  • 36
  • 61
  • Don't force tags into the title. Read http://stackoverflow.com/help/tagging on how to properly use tags – Tseng Aug 11 '16 at 08:18

1 Answers1

3

AFAIK, editing configuration does not cause IIS recycle. One of the reason maybe is that IIS is acting now merely as a reverse proxy and the application itself runs as a separate process using the Kestrel HTTP server (if you use Kestrel).

If you need to catch moment, when configuration has been changed, you can use Configuration Reload Token (Microsoft.Extensions.Configuration.ConfigurationReloadToken):

var config = builder.Build();
var token = config.GetReloadToken();
token.RegisterChangeCallback(_ =>
{
    Console.WriteLine("Changed");
}, null);

But note, the token only fires once, so need have code in the callback to a change token, if needed.

Set
  • 47,577
  • 22
  • 132
  • 150