ASP.net uses an object-oriented programming environment, each feature file is a series of classes, creating a asp.net Web page, is creating a new class.
One: How the class was created
The type of the Web page is asp.showpagetype_aspx, by using the "." In the file name of the page. Replaced with "_", the base class is System.Web.UI.Page, which defines most of the features used for the request.
By default, each ASPX page is derived from the page base class.
Instance 1: The type of the Web page is printed with the GetType () method; The BaseType property displays its base class.
<body>
The results of the operation are shown below:
Knowing that asp.net is always converted to a class, adding new functionality to a Web page is like adding a new functional approach to a class, and then we understand the common objects under ASP.net. two, Object 1,response
(inherited from System.Web.HttpResponse)
Role: Send information to the client, and control the sending process.
Instance: Dynamically creating a Web page display in the browser, changing the HTTP header name, and redirecting the client to the specified page.
Common property methods are shown in the following table
Response method
|
Description |
Write () |
Output data to the client |
Redirect () |
Booting the client browser to a new web page |
BinaryWrite () |
Output binary data to the client |
Clear () |
Clears all HTML pages in the buffer (buffer=true) |
End () |
Terminate the processing of ASP programs |
Flush () |
Send data out of buffer immediately (buffer=true) |
2,request
(inherited from System.Web.HttpRequest)
Function: Gets the parameters in the information or URL that the user submits in the Web form, and can obtain the client information.
Instance: Gets the client IP address, obtains the browser version and so on.
Common property methods are shown in the following table
Request method
|
Description |
BinaryRead () |
Read the data that the client passes by post in binary mode |
Collection
|
Description |
QueryString |
Gets the query string that the user submits in the URL string |
Form |
Get data submitted by users in a Web Form |
Cookies |
Get cookie string information in client browser |
ServerVariables |
Getting server-side environment variable information |
ClientCertificate |
Obtaining authentication information for the client browser |
Browser |
Getting information about the client browser |
3,server
(inherited from System.Web.httpServerUtility)
Role: Configure the server environment, create COM objects and scripting components, provide access to the server interface, etc.
Property
|
Description |
ScriptTimeout |
To set the maximum execution time for a script file (default 90s) |
Method
|
Description |
CreateObject () |
To create an ActiveX component that has been registered to the server, an application or Script object |
HTMLEncode () |
Converts a string to HTML format output |
HtmlDecode () |
Instead of HTMLEncode, restore the original string |
UrlEncode () |
Converts a string to a URL's encoded output |
UrlDecode () |
Restore the original string |
MapPath () |
To convert a path to a physical path |
Execute () |
Stop executing the current page, go to the new page execution, return to the original page |
Transfer () |
Stop executing the current page, go to the new page, do not return to the original page |
4,session
(inherited from System.Web.SessionState)
Role: Save user's private information on the server side
Property
|
Description
|
SessionID
|
Store user's SessionID, long Integer, automatically generated by session, with uniqueness
|
Timeout
|
Set the duration of a session
|
method
|
Description
|
Abandon ()
|
Clear Session Object
|
Events
|
Description |
Session_OnStart
|
The start event, which is activated whenever a session object is generated |
Session_OnEnd |
End event, which activates when the session object is terminated or invalidated |
5,application
(inherited from System.Web.HttpApplication)
Role: Save all user's public information on the server side
Method
|
Description |
Lock |
Lock Application Object |
Unlock |
Unlock |
Events
|
Description |
Application_OnStart |
The start event, which is activated when the Application object starts |
Application_OnEnd |
An end event that is activated when the Application object ends |
Session and Application instances
protected void Page_Load (object sender, EventArgs e)
{
//application instance, which shows the number of times the page was accessed
application. UnLock ();
Application ["Count"]=convert.toint32 (Application ["Count"]) +1;
Application.Lock ();
Response.Write ("You are the first" + convert.tostring (application["Count") + "Guest");
}
protected void Button1_Click (object sender, EventArgs e)
{
//session instance, reading input information
session["name"] = TextBox1.Text;
Response. Write ("You entered:" +session ["name"]);
}