<1> common system objects in ASP. NET
Page Object: the method that points to the page itself. The scope is the page execution period.
Request object: Read the value sent by the client during the Web Request
Response object: encapsulates the output returned to the HTTP client during the page execution period
Application Object: quasi-counter object acting on the entire program running period
Session object: The session persistence object, which is used to track sessions of a single user.
Cookie object: a way for the client to maintain session information
Server Object: provides access to the server's top-level and attribute
<2> Page Object
A page is a page object that represents a web form. It acts as a page and contains all servers.
A peripheral naming container of the control
It is of the following type: system. Web. UI. Page is a built-in object that can be used without declaration.
Common attributes: obtain or set the webpage title.
Ispostback gets a value indicating whether the page is being loaded in response to the client's sending back
Determine if it is being loaded and accessed for the first time
Isvalid gets a value to indicate whether the page verification is successful
<3> response object
A collection of server-to-client response information. It is mainly used to output information to the client.
Type: system. Web. httpresponse is also a built-in object that can be used without declaration.
Method: Write () directly outputs content on the page
Redirect () redirects to another page
<4> request object
Read the content sent by the browser so that ASP. Net can read the content sent by the client during the Web Request period.
HTTP value
Type: system. Web. httprequest is a built-in object that can be used without declaration.
Querystring ["Object Name"] obtains data transmitted through the URL path.
Form
Set of Web Server variables obtained by the servervariables attribute
You can use the Params attribute to obtain all the content transmitted in the preceding three types.
<5> Server Object
The ath method obtains the physical path of the file.
Execute method and transfer method execute scripts on another page
Htmlencode: htmldecode encodes the text into a format that can be viewed correctly in the browser.
Urlencode and urldecode URL encoding and decoding
<6> page Jump Summary
A hyperlink: <A> label href
Server control properties:
Hyperlink navigateurl
Button postbackurl
Linkbutton postbackurl
Imagebutton postbackurl
3. browser redirection
Response. Redirect ()
Example <1> browser --- request -----> a1.aspx
<2> m1.aspx --- notification redirection ---> Browser
<3> browser --- re-request ---- m2.aspx
Server jump:
Server. transer ()
Example <1> browser --- request -----> a1.aspx
<2> m1.aspx -- redirection ---> m2.aspx
<3> m2.aspx --- return result ---> Browser
Server. Execute ()
Example <1> browser --- request -----> a1.aspx
<2> m1.aspx -- redirection ---> m2.aspx
<3> m2.aspx --- return ---> m1.aspx
<4> m1.aspx -- return result ---> Browser
<8> comparison of several jump Modes
Hyperlink: controlled by the browser. The address of the browser varies depending on the situation. It has advantages, simplicity, disadvantages, and flexibility.
Server jump: the server code control, the browser address does not change, transfer () and execute (). High Efficiency cannot reach the Internet
Browser redirection: server code control, browser address change, redirect (), Internet access, low efficiency
<9> comparison of several jumps
If you want the user to decide when to convert the page and which page to go to, the hyperlink is the most suitable,
If you want to use a program to control the conversion target, but the conversion time is determined by the user, use the hyperlink control of the Web server to dynamically set its navigateurl attribute.
If you want to connect a user to resources on another server, use response. Redirect. Use response. Redirect to connect users to non-aspx resources, such as HTML pages. If you want to retain the query string as part of the URL, use response. Redirect. If you want to transfer the execution process to another ASPX page of the same web server, you should use server. transfer instead of response. redirect, because server. transfer can avoid unnecessary network communication to achieve better performance and browsing performance. If you want to capture the output results of An ASPX page and insert the results to a specific location of another ASPX page, use server. Execute. To ensure that the HTML output is valid, use response. Redirect instead of server. Transfer or server. Execute.
<2> ASP. NET status persistence
Session ----> stored on the server
Cookie -----> stored on the client
Application ----> application-level status persistence
<3> session definition and usage
Session ["Object Name"] = Value
Session. Add ("Object Name", value );
The validity period of the session variable,
If the interval between the next two access session variables exceeds the validity period, the server is automatically released.
This variable. The default value is 20 minutes.
Session. Timeout = 30 set the validity period
Session. Abandon (); Delete All
Session. Clear (); remove all keys and values
Session. Remove (Object Name) Remove the items in the session set
Session is simply a number assigned to the client by the server. Several users access one
The website of the server. When each user establishes a connection with this server for the first time, it is connected to this server.
A session is created, and the server automatically assigns a sessionid to indicate the unique ID of the user.
Id. This sesionid is a string consisting of 24 characters randomly generated by the server.
In what scenarios:
Session maintains the status of the current user and * stores it on the server.
Shopping Cart, etc.
<10> cookie Introduction
Cookie provides a way to store user-specific information in Web applications.
Cookie is a piece of text that is transmitted back and forth between the server and the client along with the request and response
Response. Cookies ["username"]. value = "das"; settings
Response. Cookies ["username"]. expires = datetime. Now. adddays (1); Validity Period
String user = request. Cookies ["username"]. value;
2nd methods:
Httpcookie hccookie = new httpcookie ("username", "Zhang San ");
Hccookie. expires = datetime. Now. addminutes (10); // The expiration time is 10 minutes.
Response. Cookies. Add (hccookie );
<12> Application Object
Store application-level data.
When the first anti-counterfeit site is used, the application layer starts sequentially and an application object is created.
This object can be used in the entire application after the creation is successful.
Objects are stored in memory every minute unless the application is closed,
Application ["user"] = "sdad"; Set
String use = application ["user "]