c# - 关于 IHttpModule.Dispose 和 Application_End 的问题

标签 c# asp.net iis iis-7

我刚刚在读这篇文章 "When is IHttpModule.Dispose method called?"我找到了这个

"The Dispose method performs any final cleanup work prior to removal of the module from the execution pipeline."

which would mean it's application-wide.

It's ok. Anyway trying by myself I found out that using the IHttpModule Dispose method and an event handler for the Application.Disposed event should be barely the same. The first occurs right after the second one.

我觉得这不是 100% 正确,即 IHttpModule.Dispose 并不总是跟在 Application_End 之后。假设我为我的应用程序运行了多个 Application 对象实例,这意味着 Application 对象的每个实例都将在其中包含单独的模块实例。现在让我们假设当应用程序池充满应用程序实例时,会发生什么?它不会开始一个接一个地处理应用程序实例,并在链中处理应用程序实例内的模块。现在这个模块的处理并不意味着 Application_End 将在那之后触发。应用程序仍在运行。我对吗?

最佳答案

是的。

HttpModules 是每个 HttpApplication。与其名称建议相反,global.asax 中的 Application_End 方法不会在每个 HttpApplicaton 的生命周期结束时触发。它在当前 AppDomain 中所有 HttpApplications 的生命周期结束时触发(当 AppDomain 被拆除时)。 Application_Start 方法也是如此。

关于c# - 关于 IHttpModule.Dispose 和 Application_End 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6698766/

相关文章:

c# - 在 WPF 中,显示图像网格的正确方法是什么?

c# - Formview:当用户尝试插入数据时检查记录是否存在 ASP.NET C#

c# - 有什么方法可以在不创建文件的情况下设置长 url 字符串吗?

c# - 新创建的MVC的_LogOnPartial文件

c# - 为 OLEDB Access 数据库使用企业库

ASP.NET HttpContext.Current.Application 生命周期

PHP 执行程序失败

iis - 对于 IE/XP 支持,使用通配符 SSL 证书是否安全?

session - 如何检查IIS是否使用粘性 session ?

c# - 需要设置一个byte[]