In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "recording the code that causes the asp.net website to stop running". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "record the code that causes the asp.net website to stop running".
It is necessary to record what caused the site to stop running. Here are the specific ways to implement it.
The copy code is as follows:
Protected void Application_End (object sender, EventArgs e)
{
RecordEndReason ()
}
/ / /
/ / record the reason why the website stops running
/ / /
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= "website Application_End, stop running, shutDownMessage=" + shutDownMessage + ", shutDownStack=" + shutDownStack
LogHelper.WriteErrorLog (reasonString,null)
LogHelper.WriteSmtp (reasonString, null)
/ / the following method records the reason for the restart and the stack information during the restart to the windows event viewer, of course, you can also record it in a text file.
/ / EventLog log = new EventLog ()
/ / log.Source = "ASP.NET 2.0.50727.0"
/ / log.WriteEntry (String.Format ("\ r\ n\ r\ nroomshutDownmessage = {0}\ r\ n\ r\ nshutshutDownStack = {1}", shutDownMessage, shutDownStack), EventLogEntryType.Information)
}
Effect screenshot
Thank you for your reading, the above is the content of "recording the code that causes the asp.net website to stop running". After the study of this article, I believe you have a deeper understanding of the problem of recording the code that caused the asp.net website to stop running, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.