奇怪的 ! Asp.net中的Application_End事件被引发多次 [英] Weird ! Application_End event in Asp.net is raised more than once

查看:134
本文介绍了奇怪的 ! Asp.net中的Application_End事件被引发多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个相同的应用程序:共享相同的物理项目和相同的应用程序池,但是它们是通过两个不同的端口80和81托管的.我使用log4Net从Application_Start和_End处理程序中进行日志.我还通过记录HttpRuntime.AppDomainAppVirtualPath来区分这两个应用程序,因为其中之一被设置为子应用程序.我发现,在回收应用程序池时,有时会为一个应用程序多次调用Application_End事件(如我所看到的虚拟路径).那是正常的吗?是因为Log4Net吗?希望有人能给我答案.

I have two same applications: sharing same physical project and same application pool but they are hosted via two different ports, 80 and 81. I use log4Net to log from the Application_Start and _End handlers. I distinguish this two applications by also logging HttpRuntime.AppDomainAppVirtualPath because one of them is set up as sub application. What I have found is that occasionally, Application_End event is called more than once for one application when application pool is recycled (as i can see the virtual path). Is that normal? Is that because of Log4Net? Hope someone could give me the answer.

推荐答案

我不认为您直接观察到过多的事件引发.您更有可能观察到某些事件处理程序的效果.由于您未提供有关代码的信息,因此您应该自己调查此案.

请执行以下操作:在调试器上全部运行,并将断点放在相关事件处理程序的开头.当您的执行在此断点处停止时,请查看调用堆栈窗口以查看调用来自何处.当您获得更多信息时,添加更多的断点.这样,您很快就会学到代码编写过程中所有丑陋的事实. :-)

祝你好运,
—SA
I don''t think you observe excessive event raising directly. More likely that you observe the effect of some event handler. As you provided no information on your code, you should investigate the case by yourself.

Do the following: run it all under debugger and put a break point on the very beginning of the event handler in question. When your execution stops at this break point, look at the call stack window to see where the call comes from. Add more break points as you get more information. This way, you will learn all the ugly truth on what happens to you code pretty soon. :-)

Good luck,
—SA


这篇关于奇怪的 ! Asp.net中的Application_End事件被引发多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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