1

You guys all know: on IIS7.5 the first request very slow. So I think maybe I can manually create a request when every time the website start, restart, after cycle time finish.....so on.

I'm search a lot , then I found Auto starting feature:http://www.schwammysays.net/auto-starting-websites-on-iis-7-5/

after I add this, I manually create a request in Application_Start() on Global.asax

protected void Application_Start()
{
     ''    original logic here     ''

 System.Threading.Tasks.Task.Factory.StartNew(new Action(() =>
            {
                try
                {
                    // send request after 100 second
                    System.Threading.Thread.Sleep(1000 * 100 * 1);
                    WebClient webClient = new WebClient();
                    using (Stream stream = webClient.OpenRead(ConfigurationManager.AppSettings["InitialPath"]))
                    {
                        if (stream.CanRead)
                        {
                            log.Debug("warm success");
                        }
                        else
                        {
                            log.Debug("can't read");
                        }
                    }

                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }));
}

but problem is : 1. that only fired when the IIS7.5 cycle time finish. not fired when restart website, start, or release it(even change web.config). 2. Some website still not fired, I don't understand.

So I'm searching Is there any other way can fired Application_Start() or create a request when website start, change, restart, IIS cycle time finish? My server is : windows server 2008 r2

1 Answer 1

3

The search term you are looking for is "application warm up".

You can use Application Initialization Module for IIS 7.5. Setup instructions can be found here and here. Note that you need to make some edits to the applicationHost.config, and you need to set it up specifically for your .NET framework version.

You can then have something like this in your web.config

<applicationInitialization
     doAppInitAfterRestart="true" >
   <add initializationPage="/" />
</applicationInitialization>

This will send a request to the root of your app (initializationPage="/") every time your app starts automatically.

Answer found here.

Sign up to request clarification or add additional context in comments.

3 Comments

my web.config file exactly like you suggest. but : 1.initializationPage not working, there is never a request access my website(I can see it on my access log). 2.it only firingApplication_Start() on global.asax when after an app pool recycle. restart , start, change website not working.
I updated my answer. Apparently, you need to update the applicationHost.config file and do an IIS restart, and possibly a few other optional setup tasks.
I already edit applicationHost.config and put autoStart="true" startMode="AlwaysRunning" for app pool . and put preloadEnabled="true" for application.So now just like I said, it not send request to "/" when restart website. it only fired Application_Start() when IIS recycle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.