This article mainly describes the record of the ASP.net web site is the reason why the implementation of the stop operation of the concrete
It is necessary to keep track of what causes the site to stop running, and here is how to implement it. The code is as follows: protected void Application_End (object sender, EventArgs e) { Recordendreason (); } &N Bsp <summary> ///Record website stop running reason ///</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= " Website Application_End, stop running, shutdownmessage= "+ Shutdownmessage +", shutdownstack= "+ shutdownstack; Loghelper.writeerrorlog (reasonstring,null); loghelper.writesmtp (reasonstring, NULL); // The following methods record the reason for the reboot and the stack information when it restarts in Windows Event Viewer, but 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 ("Rnrn_shutdownmessage={0}rnrn_shutdownstack={1}", Shutdownmessage, Shutdownstack), eventlogentrytype.information); }