I have an ASP.NET WebForms website which has a few Web.Config files for dev/UAT/production (the appropriate web.config is deployed to the relevant environment) - all of which reference a shared rewrite rule file - so that the rewrite rules themselves don't have to get duplicated into each web.config. This works great
<rewrite>
<rules configSource="WebConfigRewrites.Config" />
</rewrite>
However, if I add a new rewrite rule to this file, then the rule doesn't take effect until I restart IIS. If I recycle the application pool, or restart the website in IIS the new rule doesn't work (e.g. a rewrite URL will throw a 404 until I restart IIS)
Is there any way around this? If I bring in the rules into the web.config then recycling the apppool, or even updating the web.config will cause these new rules to work - but at the cost of having to duplicate all the rules across several files.
Having to restart IIS itself is really rubbish, as it causes the site to instantly respond with a "service unavailable" 503 error.
Is there any other way around this?
Server is Windows Server 2016, IIS 10.0.14393
As the discussion under comments is lengthy, post a summary here to avoid confusion.
Usually your edits in URL rewrite rule section in web.config
takes effect immediately, as IIS monitors <system.webServer>
actively in web.config
files.
But, when you moved the rules to an external file via configSource
, you observed that changes to those rules are no longer picked up by IIS immediately. That seems to indicate IIS does not monitor such external files actively. If you want to confirm that's by design or not, the only way is to contact Microsoft support via https://support.microsoft.com.
The workaround is also easy that you "touch" the monitored files like web.config
, so that manually trigger configuration refresh.