Learn ASP. NET once again contacted B/s development. Here is a summary of the macro structure of ASP. The six main objects in ASP. NET are described in detail later.
1.Request obtains data from the client, including form-based data and parameter list information sent through the URL, and can receive cookie information from the user.
Request is a concrete object of class HttpRequest. The main attributes are:
The Request.Form property gets the data, which, through this property, reads
form data between: Note that the submission method should be set to "Post".
The Request.QueryString property gets the data and can get the collection of HTTP query string variables. That is, the address information can be read. Note the Commit method is set to "Get".
The difference between post and get
There are two types of data sent (in HTML): Post and get, which send data through the table one-way server side of ASP. Get is to append the transmitted data to the URL, and the Post method is to encapsulate the transmitted data into a data set for transmission past.
Reading of information when the Post method
String strusername = Request.Form.Get ("txtUserName"). ToString (); Note that a form is equivalent to a collection, so there are several ways to get the appropriate data. String strusername=request.form["txtUserName"]. ToString ();
Read of information when Get method
String strusername=request.querystring["txtUserName"]. ToString ();
String Strusername=request.querystring.get ("txtUserName"). ToString ();
Summary
Either method of submission can be used in this way: request["txtUserName"]. ToString (); Get data.
2.Response is used to output data to the client, including outputting data to the browser, redirecting the browser to another URL, or outputting to the browser
Response is an object of class HttpResponse. Properties and methods:
Response.Write () Sends string information to the client.
The Response.Buffer is used to control whether the response cache is used and is true by default.
Response.Clear () empties the data in the buffer so that no data sent to the browser in the buffer is emptied.
3.Server provides access to properties and methods on the server
Its class name is HttpServerUtility, and the main properties and methods are:
MachineName: Gets the computer name of the server.
Scrpttimeout: Used to specify the time period at which the script runs on the server before it terminates.
Method Description:
CreateObject creates a server instance of a COM object.
Execute executes another ASPX page on the current server, executes the page, and then returns to this page for execution.
HTMLEncode HTML-encodes the string to be displayed in the browser and returns the encoded string.
HtmlDecode decodes the HTML-encoded string and returns the decoded string.
MapPath returns the physical file path corresponding to the specified virtual path on the Web server.
Transfer terminates execution of the current page and begins execution of a new page for the current request.
UrlEncode encodes a string representing the URL so that it can be reliably transmitted from the Web server to the client via a URL.
UrlDecode decodes a URL string that has been encoded and returns the decoded string.
Urlpathencode URL-encodes the path portion of the URL string and returns the encoded string.
4.Application a state object that acts on the entire application.
Method:
Add or create an object
Application.add ("key", value), or application ("key") =value;
Gets the value of an object in the Application collection
int i = (int) application ("key"), or int i = application.contents["key"], or int i = application.get ("key")
Updating object values in a collection
Application.set ("key", value), or application["key"] = (int) application["key"] +1; it is best to add a lock mechanism when updating: application. Lock () and Application.UnLock ().
removing objects
Application.remove ("key"); Removes the specified object. Application.removeall (), or application.clear () removes all objects.
Basic events
Application_start,application_end and Application_Error. These events are in the Global.asax file. The Global.asax file is an optional (can not have only one) file that contains the code (event) that responds to the application level and session raised by an ASP. NET application or HTTP module.
5.Session session-level objects that users track a single user's session. For example, the implementation of Web site traffic. Methods and properties are similar to application.
6.Cookie, with application and session, save data information. is a piece of text that the Web server saves on the user's hard disk. A cookie allows a Web site to save information on a user's computer and then retrieve it later. Pieces of information are stored in the form of ' key/value ' pairs.
A cookie is a text file stored on a client's hard disk that stores information about a specific client, session, or application, and corresponds to the HttpCookie class in. Net.
There are two types of cookies: Session cookies and persistent cookies. The former is temporary, and once the session state ends it will no longer exist; the latter has a definite expiration date, and the cookie is stored as a text file on the user's computer before it expires.
Creating and outputting cookies to the client on the server can take advantage of the response object implementation.
Learning experience: The above is an introductory summary of the objects in ASP. NET video, the most harvested is the use of the control, in addition to let me feel fun there are two categories, one is the validation control, including required fields, comparison controls, range comparisons, regular expressions, custom validation and validation summary. Through these verification to achieve our usual online registration information of the Basic authentication function. The other is the use of the DataSet object and the. NET Data provider in ADO and the control template that displays the data. Some of the controls introduced in ASP. have been used in beef brisket, and they have a deeper understanding of the video's explanation and implementation examples.
ASP. NET Learning Summary