发布于 2016-06-24 13:07:41 | 111 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


这篇文章主要介绍了记录asp.net网站是什么原因导致停止运行的具体实现
记录网站是什么原因导致停止运行还是有必要的,下面是具体的实现方式。
 
protected void Application_End(object sender, EventArgs e) 
{ 
RecordEndReason(); 
} 

/// <summary> 
/// 记录网站停止运行原因 
/// </summary> 
protected void RecordEndReason() 
{ 
HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetField, 
null, 
null, 
null); 
if (runtime == null) 
return; 
string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage", 
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField, 
null, 
runtime, 
null); 
string shutDownStack = (string)runtime.GetType().InvokeMember( 
"_shutDownStack", 
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField, 
null, 
runtime, 
null); 
string reasonString="网站Application_End,停止运行,shutDownMessage=" + shutDownMessage + ",shutDownStack=" + shutDownStack; 
LogHelper.WriteErrorLog(reasonString,null); 
LogHelper.WriteSmtp(reasonString, null); 
//以下方法将重启的原因和重启时的堆栈信息记录到了windows的事件查看器中,当然你也可以记录到文本文件中。 
//EventLog log = new EventLog(); 
//log.Source = "ASP.NET 2.0.50727.0"; 
//log.WriteEntry(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}", shutDownMessage, shutDownStack), EventLogEntryType.Information); 
} 

效果截图


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务