虎克的博客

Enthusiasm Biogeography-Biodiversity Informatics-Data Sciences

ASP.NET的一些基本概念和术语-ASP.NET如何工作

| Comments

目录

ASP.NET的事件模式(ASP.NET Event Model)

事件处理器(event handler):event handler 用来决定当一个事件被激发是的处理方式,比如当用户点击鼠标或者是用户从一个下拉列表中选中某个选项等等。

在.NET Framework中, 所有的事件处理器都有一个特定的方法签名(method signature)—也就是说方法的返回类型(return type)和参数(parameters)。事件处理器都是void方法,它接收两个参数:一个对象参数(object parameter)和事件声明参数(EventArgs parameter)。对象参数指激发事件的对象。例如:如果你在不同的控件使用相同的event handler,对象参数将用来判断是哪个控件激发了该事件。EventArgs parameter包含说明特定事件的信息。例如:ImageClickEventArgs parameter包含用户点击某个图片的位置信息(x和y坐标)。ASP.NET的事件处理过程不同于一般Windows应用程序在于事件的激发是发生在客户端,然后传输到服务器端进行处理。

回传(Postback)

postbackis the process by which the browser posts information
back to itself (i.e., posts information back to the server by requesting the same page). Postback in ASP.NET only occurs within Web Forms (i.e., within a form element with runat=server), and only server controls postback information to the server. Each cycle in which information is displayed and then posted back to the server is sometimes also called a round trip.

 

Page and Control Events

View State and Control State

It is a specially encoded string that is used to retain page and form information between requests and is stored within a hidden HTML <input> element. All page elements not posted back via the standard HTTP POST mechanism are stored within this string.

Page Lifecycle

Page and control events occur in a certain order, which is called the page lifecycle.

Cross-Page Posting

ASP.NET Code Compilation

The Page Class

Request: The Request property of the Page class returns an HttpRequest object. This HttpRequest represents the HTTP values sent by the browser with its request. It contains members for retrieving query string or form parameters, cookie data, as well as information about the requesting browser.

HttpRequest class

Response: The HttpResponse class represents the server’s HTTP response to the current request.

HttpResponse

Server: The Server property of the Page class returns an HttpServerUtility object.

HttpServerUtility class

Response.Redirect Versus Server.Transfer

两种方法都是重新定向到指定的页面,前者要形成一个客户端到服务器的响应Round trip,因此客户端的浏览器地址栏会出现更新;后者允许较快,因为它是直接加载请求的页面,因此不存在浏览器地址栏的更新,

ASP.NET Application Lifecycle

1、User Requests ASP.NET Resource from Server

An ISAPI extension is a Windows DLL that can be directly invoked by
a URL and that interacts and works with a request to a Web server; for ASP.NET,
the extension is aspnet_isapi.dll. An ISAPI filter, on the other hand, is a

Windows DLL that modifies the incoming and outgoing data stream to and from
IIS; for ASP.NET, the filter is aspnet_filter.dll, and is used only to preprocess
cookieless session state.

 

ASP.NET worker process (aspnet_wp.exe), which then takes over and controls the execution of the request. This worker process is a small Win32 executable that loads and hosts the CLR. Generally, there is only one instance of this process running on the machine; that is, all future requests are routed through this one worker process (see Figure 2.15). However, if there are multiple CPUs on the Web server, each CPU can run a separate single worker process.

IIS 6 generic worker process (named w3wp.exe)

IIS application pool

Comments