多少次被System.Web.HttpApplication是每个进程初始化 [英] how many times is System.Web.HttpApplication is initialised per process

查看:209
本文介绍了多少次被System.Web.HttpApplication是每个进程初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有的Global.asax 从我创建了从扩展的自定义类,名为 MvcApplication 扩展 System.Web.HttpApplication

I have the global.asax which extends from a custom class I created, called MvcApplication which extends from System.Web.HttpApplication.

在它的构造,它记录应用程序启动按如下:

In it's constructor, it logs application start as per below:

protected MvcApplicationGeneral()
{
    _log.Info("logApplicationStartToTextFile");
}

当我去日志文件看,这好像是叫的次数很多,不只是每个应用程序启动一次。我放在的Application_Start 另一个日志条目,这似乎是一次调用。是的Global.asax 类,每个请求实例化,或者更频率比每个应用程序只有一次?

When I went to look in the log file, this seems to be called A LOT of times, not just once per application start. I placed another log entry in Application_Start and that seems to be called only once. Is the Global.asax class instantiated per request, or much more frequently than just once per application?

推荐答案

创建和集中处理requests.in一个asp.net应用程序生命周期对象HttpAppliction的多个intances。
是的Application_Start将只调用一次。

Multiple intances of HttpAppliction objects are created and pooled to process the requests.in the lifecycle of an asp.net application. yes Application_Start will be called only once.

引用<一个href=\"http://www.$c$cproject.com/Articles/73728/ASP-NET-Application-and-Page-Life-Cycle\">http://www.$c$cproject.com/Articles/73728/ASP-NET-Application-and-Page-Life-Cycle

节选:
一旦创建了所有的核心ASP.NET对象,HttpApplication的对象被创建为服务请求。如果你的系统中有一个'的Global.asax文件,那么在的Global.asax文件的对象将被创建。请注意,Global.asax文件从HttpApplication的类继承。
注意:第一次ASP.NET页面连接到应用程序,'的HttpApplication'的一个新实例被创建。说和做,以最大限度地提高性能,一个HttpApplication实例可能被重用多个请求。

excerpt: Once all the core ASP.NET objects are created, ‘HttpApplication’ object is created to serve the request. In case you have a ‘global.asax’ file in your system, then the object of the ‘global.asax’ file will be created. Please note global.asax file inherits from ‘HttpApplication’ class. Note: The first time an ASP.NET page is attached to an application, a new instance of ‘HttpApplication’ is created. Said and done to maximize performance, HttpApplication instances might be reused for multiple requests.

这篇关于多少次被System.Web.HttpApplication是每个进程初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆