gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:08:22 25 4
gpt4 key购买 nike

我刚刚在读这篇文章 "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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com