Request and response of six objects in Asp.net

Source: Internet
Author: User
Request and response of six objects in Asp.net

 

The six objects in ASP. NET are essentially only attributes in context, not objects strictly.

1. Request --> Read the value sent by the client during the Web Request

2. Response --> encapsulate the output returned to the HTTP client after the page execution period

3. Server --> provides access to properties and methods on the server

4. Application --> Status objects acting on the entire Runtime

5. session --> session state persistence object, used to track sessions of a single user

6. Cookie --> one way for the client to keep session information

 

 

Request--> Read the value sent by the client during the Web request, that is, read the request message data sent from the browser.

To read HTTP request message data, you must understand the data submitted by the browser.

There are two main types: one is the parameters sent from the form using post, and the data exists in the Request Message style. Correspondingly, on the server side, the method for obtaining data submitted by the browser is context. Request. Form ["XXX"].

The other is through the URL parameter (which is consistent with the parameters sent from the form using get), and the data exists in the URL string. The method for obtaining the data is context. Request. querystring ["XXX"].

In addition, you can directly use context regardless of the data submitted by the browser. request ["XXX"] to read data, which is also feasible, but the effect is reflected in efficiency, directly using context. request ["XXX"] to read data is certainly slower, which is the difference between large-scale retrieval and small-scale retrieval.

 

Response--> Encapsulates the output returned to the HTTP client after the page execution period, that is, the HTTP response packet data.

Its Class Name Is httpresponse

Attributes and Methods

Write () sends string information to the client

Whether the bufferoutput attribute uses Cache

Clear () Clear Cache

Flush () forces the output of all cached data

Redirect () webpage redirection address

End () stops running the current page

Writefile () reads a file and writes it to the client output stream (essence: open the file and output it to the client .)

1. response. Write variable data or string

Response. Write (variable data or string)

2. The redirect method of the response object redirects the client browser to another URL to jump to another webpage.

For example:

Response. Redirect ("http://www.cnblogs.com/crazypig ")

3. response. End () Terminate the running of the current page

4. response. writefile (filename)

Filename indicates the name of the file to be output to the browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.