This article mainly introduces the usage of request and response in asp. Friends who need it can refer to it.
Usage of request:
request has three methods for obtaining form values, which are used for obtaining different form submission methods. A form can simply be thought of as a collection of parameters to be passed on the page, and its submission methods include two post and get methods. These two methods correspond to different receiving methods, and their specific implementation is as follows:
1. For the value-getting method of the form submitted by the post method, use the get method of the form attribute of the request to obtain the required field identifier. For example, the code to get the value of txtUserName in the submitted form and put it into the string usrName is as follows, string userName=Request.Form.Get(txtUserName).ToString();
2. For the value acquisition method of the form submitted by the get method, use the field identifier in the QueryString attribute of the request to obtain the value. For example, the code to get the value of txtUserName in the submission form and put it into the string usrName is as follows, string userName=Request.QueryString[txtUserName].ToString();
3. For methods that are applicable to both methods, use the index value of request to obtain the value in the desired form. The code is as follows:
string userName=Request[txtUserName].ToString();
Among them, their advantages and disadvantages are as follows:
1. This method is a method to obtain the value of the form submitted by the post method. For the post value method, the parameter value passed will not be displayed in clear text in the URL.
2. This method is a method to obtain the value of the form submitted by the get method. The disadvantages of using the get value transfer method are:
(1), clear code display,
(2) Limited length;
Advantages: (1) You can directly define a url and pass the value;
Function: (1) It is convenient to apply templates when making news
response method
The most important methods used here are response.write(string) and response.redirect(url).
The function of response.write(string) is to return data from the server to the client (write data)
The function of response.redirect(url) is to redirect to another web page on the server side.