如何保持 HttpModule 的活动(也称为将其注册为单例)

发布于 2024-08-31 08:18:08 字数 376 浏览 2 评论 0原文

我很确定我在某处见过这个,但我似乎无法在任何地方找到它。我有一个可以跨多个请求使用的 HttpModule。换句话说,不需要在每个请求上创建一个新的模块实例,它只需要创建一次。这对任何人来说都敲响了警钟吗?如果是这样,配置以这种方式工作的方法是什么?

更新 我实际上正在考虑 IHttpHandler,它有一个名为 IsReusable 的属性。每个应用程序仅创建一次 HttpModule: http://www.devx .com/vb2themax/Article/19901/0/page/2

I pretty sure I've seen this somewhere but I can't seem to find it anywhere. I have an HttpModule that can be used across multiple requests. In other words instead of creating a new instance of the Module on every request it only ever needs to create it once. Does this ring a bell to anyone? If so, what's the method for configuring to work this way?

UPDATE
I'm was actually thinking about IHttpHandler which has a property called IsReusable. HttpModules are only ever created once per application: http://www.devx.com/vb2themax/Article/19901/0/page/2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你穿错了嫁妆 2024-09-07 08:18:10

我想您可以将功能移至静态类,然后从 HttpModule 调用该类。这样,HttpModule 本身将不会保持活动状态,但您希望共享的功能和状态将会保持活动状态。

I guess you could move the functionality to a static class, and call that class from your HttpModule. That way the HttpModule itself will not be kept alive, but the functionality and state that you wish to share will be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文