我可以从Application_End()参数获取任何有趣的数据吗? [英] Is there any interesting data I could obtain from Application_End() parameters?

查看:165
本文介绍了我可以从Application_End()参数获取任何有趣的数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Azure上部署的ASP.NET应用程序中,我想记录尽可能多的有用数据.有Application_End()方法:

In my ASP.NET application that I deploy on Windows Azure I want to log as many useful data as possible. There's Application_End() method:

protected void Application_End(object sender, EventArgs e)
{
}

调用

,其中sender System.Web.HttpApplicationFactory ,而e仅是System.EventArgs.使用这些参数,我所能做的只是记录它们的类型,这不是很有用.

which is invoked with sender being System.Web.HttpApplicationFactory and e being just System.EventArgs. With such parameters all I can do is just log their types which isn't very useful.

我可以从这些参数中获取任何有用的数据吗?在某些情况下,是否使用具有其他(更有用的)实际类型的参数调用Application_End()?

Can I obtain any useful data from these parameters? Are there cases when Application_End() is invoked with parameters that have other - more useful - actual types?

推荐答案

IIS,包括class HttpRuntime,可以下载源.仔细的分析表明,确实事件参数始终是相同的,并且没有传达任何有用的信息.该事件的调用堆栈也没有用-始终如此

IIS, class HttpRuntime included, sources can be downloaded. Careful analysis shows that indeed the event parameters are always the same and convey no useful information. The call stack for the event is also useless - it is always

my Application_End(Object sender, EventArgs e)
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Web.HttpApplication.InvokeMethodWithAssert(MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs)
at System.Web.HttpApplication.ProcessSpecialRequest(HttpContext context, MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs, HttpSessionState session)
at System.Web.HttpApplicationFactory.Dispose()
at System.Web.HttpRuntime.Dispose()
at System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

但是...有 System.Web.Hosting.HostingEnvironment.ShutdownReason ,可以从Application_End()内部检索,并且由HttpRuntime在启动应用程序关闭时设置.

but... There is System.Web.Hosting.HostingEnvironment.ShutdownReason that can be retrieved from within Application_End() and that is set by HttpRuntime when the application shutdown is being initiated.

所以有趣的数据"是System.Web.Hosting.HostingEnvironment.ShutdownReason.

另请参见这个密切相关的问题

这篇关于我可以从Application_End()参数获取任何有趣的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆