HttpApplication.Init () 方法只被触发一次吗?
启动 ASP.NET 4.0 应用程序后,我在 HttpApplication.Init () 的重写中增加了应用程序变量的计数。当应用程序第一次运行时,init 方法将被调用,并且 count 将为 1。我注意到,当下次应用程序被调用时,init 方法将不会被执行,并且 count 将始终保持为 1。
这是预期的行为还是我做错了什么,或者我对HttpApplication.init()的理解是错误的。
任何帮助将不胜感激!
谢谢, 普拉迪普
Upon startup of my ASP.NET 4.0 application, I increase count of my application variable inside an override of HttpApplication.Init (). When application runs first time the init method will get called and count will be 1. I noticed that when next time application gets called init method will not get executed and count will always be remained 1.
Is this intended behavior or I am doing something wrong, or my understanding on the HttpApplication.init () is wrong.
Any help would be appreciated!
Thanks,
Pradeep
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HttpApplication
对象用于处理 HTTP 请求。这些类似于连接,创建起来很昂贵,因此工作进程将实例化所需的数量并为其创建一个池。现在,每个请求都由该池中的对象提供服务。HttpApplication
object is used to process a HTTP request. These are similar to connections and are expensive to create, so the worker process will instantiate as many required and create a pool for the same. Now every request is served by the objects in this pool.是的,这是预期的行为:Init 方法被设计为仅触发一次,以便允许您“添加自定义一次性初始化代码”
Yes, this in the intended behavior: the Init method is designed to only fire once in order to allow you 'to add custom one-time initialization code'