【问题标题】:How do I add a Application_End handler without using global.asax?如何在不使用 global.asax 的情况下添加 Application_End 处理程序?
【发布时间】:2012-02-23 15:25:37
【问题描述】:

我正在编写一个 http 模块,我想添加一个在(且仅当)appdomain 被回收时调用的方法。我不想向 global.asax 添加任何内容,我想在 http 模块中以编程方式进行。

但是,在模块的Init 方法中传递的HttpApplication 实例上似乎没有End 事件。如何订阅Application_End 事件?

【问题讨论】:

  • 在应用程序域被回收时,您要实现什么目标?
  • 将一些数据发送到已存储在内存中的 Web 服务
  • 我需要在应用端保存日志

标签: asp.net httpmodule application-end


【解决方案1】:

怎么样:

AppDomain.CurrentDomain.DomainUnload +=new EventHandler(CurrentDomain_DomainUnload);

我认为这比 Application.End准确,应该涵盖回收。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 2016-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多