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.