[英]How manually create first request for asp.net mvc on iis7.5 when every time restart or release the website?
You guys all know: on IIS7.5 the first request very slow . 你们都知道:在IIS7.5上 ,第一个请求非常慢 。 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/ 我进行了很多搜索,然后发现了自动启动功能: 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 添加此代码后,我在Global.asax的 Application_Start()中手动创建一个请求
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. 但问题是:1.仅在IIS7.5循环时间结束时才触发。 not fired when restart website, start, or release it(even change web.config).
重新启动网站,启动或释放网站时不会触发(甚至更改web.config)。 2. Some website still not fired, I don't understand.
2.有些网站仍然没有被解雇,我听不懂。
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? 因此,我正在搜索网站启动,更改,重新启动,IIS循环时间结束时,还有其他方法可以触发Application_Start()或创建请求吗? My server is : windows server 2008 r2
我的服务器是: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 . 您可以将应用程序初始化模块用于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. 请注意,您需要对
applicationHost.config
进行一些编辑,并且需要专门针对.NET Framework版本进行设置。
You can then have something like this in your web.config
然后,您可以在
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. 每次您的应用程序自动启动时,这会将请求发送到您的应用程序的根目录(
initializationPage="/"
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.