Six giants of ASP. NET-built-in objects (1)

Source: Internet
Author: User

Six giants of ASP. NET-built-in objects (1)

ASP. NET provides six built-in objects: Request, Response, Application, Session, Server, and ObjectContext. These objects collect current application requests, user information, and browser response information to complete page management and information transmission.

Request object

Used to retrieve information in a request sent from a browser to the server. The Request object reads the value sent by the client during a Web page Request.

Usage:

1) When method = "post"

String userName = Request ["txtUserName"]. ToString ();
String userPwd = Request ["txtUserPwd"]. ToString ();

String userName = Request. Form. Get ("txtUserName ");
String userPwd = Request. Form. Get ("txtUsrPwd ");

2) When method = "get"

String userName = Request. QueryString ["txtUserName"]. ToString ();

String userPwd = Request. QueryString ["txtUserPwd"]. ToString ();

Response object

Sends data from the server to the browser.

Usage:

Attributes and methods:

Write () directly sends string information to the client

Redirect () Jump directly to a webpage

Response. Write ("the user name is incorrect! ");

Response. Redirect ("WebForm2.aspx ");

Application Object

It is used to share application-level information and maintain a group of variables of the entire application. These variables can be accessed by all users of the application.

Share.

Usage:

1) save information: Application ("") = value;

2) add a key: application. add ("key name", value );

3) delete key: application. remove ("key name", value );

These are just a preliminary understanding of these three objects. Of course, you need to use these objects more frequently before you can have a deeper understanding of these contents during use, this knowledge can be used only after being studied.

Related Article

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.