preLoad firing after "on idle" recycle, but not after web.config changeRSS

5 replies

Last post Oct 26, 2018 10:19 PM by Gerardo_grr

  • preLoad firing after "on idle" recycle, but not after web.config change

    Dec 06, 2012 02:40 AM|pjaffe|LINK

    I recently set up the Application Initialization module on IIS 7.5 on a Windows Server 2008 R2 machine with ASP.NET 4.0 running an MVC 3 web application.  It appeared to work like a charm.  If I spin up IIS, I immediately see the web application spin up whose applicationPool was set to startMode="AlwaysRunning" and site had preLoad="true" in my applicationHost.config.  I then set my "Idle timeout" to a low number, and happy saw that time arrive and my application immediately spun back up again.  So, everything seemed to be working great.  FYI, I didn't have to bother setting up anything in my web.config to indicate where the preLoad request should be directly, nor did I bother with providing a resource that would render during preLoad/warmup.

    However, when I make a change to the web.config by hand, the AppDomain appears to unload as expected, however the preLoad event doesn't appear to trigger again.  Hence my web application appears dead in the water until it receives a browser initiated http request.  The same seems to be true when I push a new deployment over an existing deployment using a remote MS Deploy.  I'm guessing that is effectively the same as a manual update to the web.config, but also typically deploys new dlls which I imagine would have a comparable behavior, but I haven't yet tried that case as well.

    So, I'm wondering if anyone has explicitly seen preLoad firing after a manual modification to the web.config, in which case I'll start trying to figure out what configuration I may have wrong.  Or is this a short coming of the IIS module? Or am I misunderstanding how it is expected to work?

    Thanks.

    Pete

  • Re: preLoad firing after "on idle" recycle, but not after web.config change

    Jan 31, 2013 12:14 PM|belugga|LINK

    Hi,

    I am having the same issue.  Has any one found a solution?

  • Re: preLoad firing after "on idle" recycle, but not after web.config change

    Jan 03, 2014 04:20 AM|AKuryan|LINK

    Hi,

    your question seems to be answered in http://weblog.west-wind.com/posts/2013/Oct/02/Use-IIS-Application-Initialization-for-keeping-ASPNET-Apps-alive

    in section "What about AppDomain Restarts?". Actually, it explains the fact, that AppDomain restart, which is fired on web.config change, is not covered by this module.

    And there is also a recipe being prepared :)

  • Re: preLoad firing after "on idle" recycle, but not after web.config change

    Jan 03, 2014 10:56 AM|pjaffe|LINK

    Thank you so much AKuryan for linked that blog post into this thread.  Rich Strahl's explanation and workaround using Application_End to initiate a new web request to spin back up the AppDomain all seems to make sense and I imagine should work, since my understanding is that during AppDomain unloading, all future requests (and hence the one the Application_End initiates) get routed to the new AppDomain.

    It does cross my mind as to whether to include that web request in the instance I register with HostingEnvironment.RegisterObject(...) and therefore maybe could ensure my background tasks are truly stopped before they spin back up under the new App Domain.  But it may be more intuitive and a better separation of concerns to keep those separate.  Or maybe I should try to understand if there is a guarantee as to the order in which the IRegisterObject instances are called (and completed) versus the Application_End lifecycle hook.

    Thanks again AKuryan.

  • Re: preLoad firing after "on idle" recycle, but not after web.config change

    Nov 23, 2014 11:23 AM|huangjinshe|LINK

    Hi, How do you handle start website?  On my IIS, it's only called when the IIS recycle. but when I stop and start website. it still can't .

    did you try using initializationPage feature? it's not send request on here.....

  • Re: preLoad firing after "on idle" recycle, but not after web.config change

    Oct 26, 2018 10:19 PM|Gerardo_grr|LINK

    @huangjinshe:

    In your web.config

    <applicationInitialization
    doAppInitAfterRestart="true"
    skipManagedModules="false">
    <add initializationPage="/" hostName="localhost" />
    </applicationInitialization>
    </system.webServer>

    in your applicationhosts.config:

    <application path="/MyWebApp" applicationPool="DefaultAppPool" serviceAutoStartEnabled="true" preloadEnabled="true">
    <virtualDirectory path="/" physicalPath="C:\xxx.WebApp" />
    </application>
    ...

    <applicationPools>
       <add name="DefaultAppPool" autoStart="true" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />

    ...