如何保持 HttpModule 的活动(也称为将其注册为单例)
我很确定我在某处见过这个,但我似乎无法在任何地方找到它。我有一个可以跨多个请求使用的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您可以将功能移至静态类,然后从 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.