2

I was read tons of articles where is specified that I can disable asp.net application recycling after web.config changes by using fcnMode="Disabled".

I want to keep my application state and not allow recycle after any configuration changes until I decide to recycle.

I prepare such configuration for IIS.

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.7.2"/>
        <httpRuntime targetFramework="4.7.2" fcnMode="Disabled"/>
    </system.web>
</configuration>

Every change of Web.Config in root of application cause recycle.

I write such simple Controller to test it. It save in static variable start of application (this is simulation of state). I view page in browser then touch/edit web.config file to see if IIS will reload application or not. I see every time that after series of F5/refresh time is not changing but after touch/edit everytime time is changing - it means that state is lost and application is recycled.

I tested it also in debugger and Controller is changing so application is recycling.

public class HomeController : Controller
{
    public static DateTime startDate = DateTime.Now;

    // GET: Home
    public ActionResult Index()
    {
        ViewBag.StartDate = startDate;
        return View();
    }
}

Here is view:

<h2>Index</h2>

<pre>
Process: @(System.Diagnostics.Process.GetCurrentProcess().ProcessName)
Process start date: @(System.Diagnostics.Process.GetCurrentProcess().StartTime)
Application domain start date (controller static variable): @(ViewBag.StartDate)
</pre>

Read article before question:

  1. https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.fcnmode?view=netframework-4.8
  2. How to prevent an ASP.NET application restarting when the web.config is modified?
  3. 3.
Chameleon
  • 9,722
  • 16
  • 65
  • 127
  • According to https://shazwazza.com/post/all-about-aspnet-file-change-notification-fcn/, `Web.config` changes still trigger recycling (even for `fcnMode=Disabled`) – haim770 May 28 '19 at 11:12
  • How to prevent recycling if Web.config is changed? – Chameleon May 28 '19 at 11:13
  • 1
    “How to”, don't change it and no reloading happens. – Lex Li May 28 '19 at 14:19
  • I tested many configuration and fcnMode=Disable block monitoring of all, I can not block bin and enable /Views - it depend if it iis and iisexpress - each behave not the same. IIS stop refreshing Views, IISExpress refresh Views. I want to siable reclyce on bin changes and enable Views but not found solution apart dirty code hacking with reflection. – Chameleon May 28 '19 at 14:35

0 Answers0