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
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.