ASP.Net Internals

New Events

ASP.NET 2.0 provides a more granular page lifecycle method stack as compared to ASP.NET 1.x. The added methods provide a greater level of control to the Web developer. These events can be accessed through the Page object on any ASP.NET page.

Table 1 shows the comprehensive method list. The Method column displays the actual event method name, and the Active column indicates whether the event is always active or only active during PostBack actions. For example, the new TestDeviceFilter method can be used to determine which device filter is in place, and use this information to decide how to display the page. On the other hand, the new LoadControlState method only fires during a postback. This method can be overridden (in conjunction with SaveControlState) to create alternate serialization schemes for saving and restoring control state during a postback.

Table 1. Page Lifecycle methods

MethodActive
ConstructorAlways
ConstructAlways
TestDeviceFilterAlways
AddParsedSubObjectAlways
DeterminePostBackModeAlways
OnPreInitAlways
LoadPersonalizationDataAlways
InitializeThemesAlways
OnInitAlways
ApplyControlSkinAlways
ApplyPersonalizationAlways
OnInitCompleteAlways
LoadPageStateFromPersistenceMediumPostBack
LoadControlStatePostBack
LoadViewStatePostBack
ProcessPostData1PostBack
OnPreLoadAlways
OnLoadAlways
ProcessPostData2PostBack
RaiseChangedEventsPostBack
RaisePostBackEventPostBack
OnLoadCompleteAlways
OnPreRenderAlways
OnPreRenderCompleteAlways
SavePersonalizationDataAlways
SaveControlStateAlways
SaveViewStateAlways
SavePageStateToPersistenceMediumAlways
RenderAlways
OnUnloadAlways

Looking at the low level details of the page lifecycle, we can see where many of the features that are available in ASP.NET 2.0, such as themes and personalization, would naturally be implemented. For example, a theme would be processed in the IntializeThemes event, whereas personalization data would be loaded in the LoadPersonalizationData and later applied in the ApplyPersonalization method. Note that method order is extremely important with respect to which UI elements will determine the final look and feel of your Web applications.

The Request Pipeline

In ASP.NET, requests are passed from the Web server through an Internet Server Application Programming Interface (ISAPI) filter and on to the actual ASP.NET runtime.
internals_fig05.gif

Figure 5. The request pipeline

When IIS receives a request, the extension is mapped to an ISAPI filter according to the IIS settings. The extensions .aspx, .asmx, .asd, and others are mapped to the aspnet_isapi.dll, which is simply an ISAPI filter that launches the ASP.NET runtime. Once a request hits the ASP.NET runtime, it starts at the HTTPApplication object, which acts as the host for the ASP.NET Web application. The HTTPApplication object:

  1. Reads the machine and application level configuration files.
  2. Passes the request through one or more HTTPModule instances. Each HTTPModule provides a service such as session maintenance, authentication, or profile maintenance. These modules pass the request back to the HTTPApplication.
  3. Passes the request to an HTTPHandler based on the verb and the path. The verb refers to the HTTP verb used in the request (GET, POST, FTP, and so on) and the path refers to a URL within the application. Depending on how the handlers are configured, the request may be processed as an ASP.NET page (System.Web.UI.Page is an implementation of IHTTPHandler), or the request may trigger another action such as the batch-compilation of all Web pages (precomiplation.asd triggers the PrecompHandler).

In ASP.NET 2.0, this model stays intact; however, several new modules and handlers have been added to provide additional services. As with ASP.NET 1.x, you can extend, replace, or reconfigure any of the module or handler classes in order to provide your own custom functionality.

New Modules

Naturally, new HTTPModules have been added to support the new services offered in ASP.NET 2.0. Specifically, an ASP.NET application with default module settings will include new modules for:

  • SessionID—The session identification mechanism has been split off the ASP.NET 1.x Session module in order to provide greater control over cookies, URL rewriting, and other forms of session ID generation.
  • Role Management—A new module has been added for providing role-based services in support of the new user identification mechanisms. This module helps link ASP.NET applications to the role-based security built into the .NET framework.
  • Anonymous Identification—The new personalization features support anonymous users. This module helps keep track of which features an anonymous user can access, and how these features are maintained between requests.
  • Profile—The profile module links to the new profile service and helps provide user specific persistent data storage.
  • Page Counters—ASP.NET 2.0 incorporates a new module for linking to page counters and improving statistical analysis of Web traffic.

In addition to these new modules, the behaviors of some of the older modules have changed: for example, the output caching module now supports the new caching techniques described later in this white paper.

New Handlers

In addition to the new modules, ASP.NET 2.0 introduces new handlers to support the application configuration tools and other new features such as the batch-compilation request. The most important of the new handlers include the ".axd" family which process Web site administration requests. These handlers launch the internal administration tools that allow developers to configure ASP.NET users as well as other settings. The administrative handlers include:

  • Web Administration—The WebAdminHandler is the main page for the administrative Web site. This handler provides the starting point for administering ASP.NET 2.0 Web applications.
  • Trace—The ASP.NET 1.x TraceHandler has been improved and is the only "axd" handler that was available in ASP.NET 1.x.
  • Web Resources—Web resources can now be configured post-deployment thanks to the new administrative tool and the WebResourcesHandler.
  • Cached Images—The CachedImageServiceHandler provides support for caching graphical components.
  • Counters—The SiteCountersHandler works with the page counters module to provide access statistics for an ASP.NET 2.0 application.
  • Precompile—As mentioned earlier, the PrecompHandler can be used to batch-compile all of the ASPX pages in an ASP.NET application.
  • Web Part Export—The WebPartExportHandler provides support for storing and transferring Web Part layouts. Web Parts are a new mechanism for personalizing the look and contents of a portal-style Web application.

As always, the HTTPForbiddenHandler is linked to any file type that should never be returned. In ASP.NET 2.0, the list of forbidden file types has been expanded to include master pages, skin files, and other new developer components.

http://msdn.microsoft.com/library/en-us/dnvs05/html/internals.asp

转载于:https://www.cnblogs.com/chinapro/archive/2004/08/14/33268.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值