2012-05-16 28 views
0

我想知道我是否可以跟踪这一点,因为如果经常发生这种情况,我想知道它的根本原因。是否有任何时间戳记录可用于在IIS中重新启动我的网站,如何以编程方式跟踪此问题?如何检查IIS或ASP.NET工作进程是否自动重新启动我的网站?

感谢所有。

+1

http://msdn.microsoft.com/en-us/library/bb398933.aspx – zdrsh

+0

哪个版本的IIS吗? –

+1

使用WMI查询事件日志。 – vcsjones

回答

2

您可以登录原因重新启动应用程序在Global.asax中Application_End:

protected void Application_End(object sender, EventArgs e) 
{ 
    HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null); 

    string shutDownMessage = ""; 

    if (runtime != null) 
    { 
    shutDownMessage = Environment.NewLine + "Shutdown: " + 
         (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null) + 
         Environment.NewLine + "Stack: " + Environment.NewLine + 
         (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null); 
    } 
} 
+0

非常感谢,这似乎告诉我们我们正在寻找什么。 –

+0

+1非常好,很好的想法,刚才我看到了这个答案。 – Aristos

3
在Global.asax中

void Application_Start(object sender, EventArgs e) 

void Application_End(object sender, EventArgs e) 

被称为应用程序启动和结束时。您可以使用它们来记录它。现在要知道为什么您的游泳池正在重新启动,您可以简单地检查您的游泳池的设置,有很多原因可能已经设置,也许你已经设置了时间限制,可能是内存限制,也许其他设置...你可以检查他们并改变他们。

+0

我已经知道这个事件,我们正在使用它。谢谢。 –

相关问题