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