首页 > 其他 > 详细

Life Cycle Stages of IIS 7.0

时间:2020-07-19 00:10:21      阅读:41      评论:0      收藏:0      [点我收藏+]

Life Cycle Stages

The following table lists the stages of the ASP.NET application life cycle with Integrated mode in IIS 7.0.

1.A request is made for an application resource.

The life cycle of an ASP.NET application starts with a request sent by a browser to the Web server.

In Classic mode in IIS 7.0 and in IIS 6.0, the ASP.NET request pipeline is separate from the Web server pipeline. Modules apply only to requests that are routed to the ASP.NET ISAPI extension. If the file-name extension of the requested resource type is not explicitly mapped to ASP.NET, ASP.NET functionality is not invoked for the request because the request is not processed by the ASP.NET runtime.

IIS 7.0里面的经典模式和IIS 6.0里面的 request管线是和web server的管线分开的,modules仅对route到ASP.NET ISAPI扩展的request起作用。

如果请求的资源类型的文件名后缀没有显式地映射到ASP.NET,那么ASP.NET的功能就不会被调用。

In integrated mode in IIS 7.0, a unified pipeline handles all requests. When the integrated pipeline receives a request, the request passes through stages that are common to all requests. These stages are represented by the RequestNotification enumeration. All requests can be configured to take advantage of ASP.NET functionality, because that functionality is encapsulated in managed-code modules that have access to the request pipeline. For example, even though the .htm file-name extension is not explicitly mapped to ASP.NET, a request for an HTML page still invokes ASP.NET modules. This enables you to take advantage of ASP.NET authentication and authorization for all resources.

 在IIS 7.0的集成模式下,一个统一的管线会处理所有的请求。当集成管线收到一个请求,这个请求会通过所有的stages。

RequestNotification这个枚举里面的数值,对应了不同的stages。这些stages对应了HttpApplication里面的event。

using System;

namespace System.Web
{
    /// <summary>Indicates when events and other life-cycle events occur while a <see cref="T:System.Web.HttpApplication" /> request is being processed.</summary>
    // Token: 0x020000ED RID: 237
    [Flags]
    public enum RequestNotification
    {
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.BeginRequest" /> event was raised for the request and is processing.</summary>
        // Token: 0x0400057C RID: 1404
        BeginRequest = 1,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.AuthenticateRequest" /> event was raised for the request and is processing.</summary>
        // Token: 0x0400057D RID: 1405
        AuthenticateRequest = 2,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.AuthorizeRequest" /> event was raised for the request and is processing.</summary>
        // Token: 0x0400057E RID: 1406
        AuthorizeRequest = 4,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.ResolveRequestCache" /> event was raised for the request and is processing.</summary>
        // Token: 0x0400057F RID: 1407
        ResolveRequestCache = 8,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.MapRequestHandler" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000580 RID: 1408
        MapRequestHandler = 16,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.AcquireRequestState" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000581 RID: 1409
        AcquireRequestState = 32,
        /// <summary>Indicates a point in the application life cycle just before the handler that processes the request is mapped.</summary>
        // Token: 0x04000582 RID: 1410
        PreExecuteRequestHandler = 64,
        /// <summary>Indicates that the handler that is mapped to the requested resource is being invoked to process the request.</summary>
        // Token: 0x04000583 RID: 1411
        ExecuteRequestHandler = 128,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.ReleaseRequestState" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000584 RID: 1412
        ReleaseRequestState = 256,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.UpdateRequestCache" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000585 RID: 1413
        UpdateRequestCache = 512,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.LogRequest" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000586 RID: 1414
        LogRequest = 1024,
        /// <summary>Indicates that the <see cref="E:System.Web.HttpApplication.EndRequest" /> event was raised for the request and is processing.</summary>
        // Token: 0x04000587 RID: 1415
        EndRequest = 2048,
        /// <summary>Indicates that processing of the request is complete and that the response is being sent.</summary>
        // Token: 0x04000588 RID: 1416
        SendResponse = 536870912
    }
}

 

2.The unified pipeline receives the first request for the application.

When the unified pipeline receives the first request for any resource in an application, an instance of the ApplicationManager class is created, which is the application domain that the request is processed in. Application domains provide isolation between applications for global variables and enable each application to be unloaded separately. In the application domain, an instance of the HostingEnvironment class is created, which provides access to information about the application, such as the name of the folder where the application is stored.

During the first request, top-level items in the application are compiled if required, which includes application code in the App_Code folder. You can include custom modules and handlers in the App_Code folder as described in Managed-code Modules in IIS 7.0 later in this topic.

收到请求后,首先创建ApplicationManager,这个是一个用来处理request的application domain。并且它会创建HostingEnvironment。第一个请求的时候,还会编译Application的顶级的items,比如App_Code下面的自定义modules和handlers。

 

3.Response objects are created for each request.

After the application domain has been created and the HostingEnvironment object has been instantiated, application objects such as HttpContextHttpRequest, and HttpResponse are created and initialized.

The HttpContext class contains objects that are specific to the current application request, such as the HttpRequest and HttpResponse objects.

The HttpRequest object contains information about the current request, which includes cookies and browser information.

The HttpResponse object contains the response that is sent to the client, which includes all the rendered output and cookies.

The following are some key differences between IIS 6.0 and IIS 7.0 running in Integrated mode and with the .NET Framework 3.0 or later:

 

Life Cycle Stages of IIS 7.0

原文:https://www.cnblogs.com/chucklu/p/13338006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!