Subscribe to Feed

17Sep

How to programmatically determine when Web.Config Changes?

Posted by admin as .Net, Asp.Net, Microsoft, Technology, Web

 

On some occasions you would want to run some code for every change in the configuration file, like reload the cache etc.. A change in web.config prompts the app domain to reload. So one should be able to look for application domain shutdown reason to verify a configuration change. Here is how you do can do it

In you Global.asax.cs file add the following code

protected void Application_End(object sender, EventArgs e)
{
    if (HostingEnvironment.ShutdownReason == 
                           ApplicationShutdownReason.ConfigurationChange)
    {
        // Do Something
    }
}

Hope this helps someone.

Comment Form

 

 

Subscribe to Feed

Categories

Links

Dev Jobs