In asp.net, the dynamic interaction of the client is implemented through the response and request objects, which play both the server and the client
information dissemination, where the response object is used to receive data submitted by the client browser, and the request object's function is to bring the server
Data is sent to the client browser.
Because the ASP.net page contains the default reference (using system.web) to the System.Web namespace, which contains the HttpContext class. Page class,
The HttpRequest class and HttpResponse class relationships are shown in the following illustration. When you load a page page, you also reference the Hettprequest class and the
HttpResponse class. Two classes as page properties request and response exist so that we can use the Page_Load method directly
The property request object and the Response object for the page.
a Request Object
The request object can be used to access any information that is delivered by an HTTP request, including a parameter passed from the POST method of an HTML form or a GET method
Number, cookies, and user authentication. Here are a few common properties. 1 Properties 1) Form
Gets a collection of variables in the form. In fact, it is a container, the page needs to be passed between the information stored in the form, the Web page can receive. When
When method has a property value of post or get, all the HTML controls in the <form> segment that are submitted for the request/web the value of the control unit, each
Members are read-only. The following two methods are implemented in code:
<!--Use the Post method-->
<form id= "Form2" runat= "Server" method= "POST" >
<!--use Get method-->
< Form id= "Form1" runat= "Server" method= "get" >
Use post to get form forms
protected void Btnok_click (object sender, EventArgs e)
{
string name;
Name = request.form["TextBox1"];
Response.Write (name);
Obtain form form
protected void Btnok_click (object sender, EventArgs e)
{
string name
using Get method; name = Request.QueryString ["TextBox1"];
Response.Write (name);
2) QueryString
A value that is attached to the name/value after the URL of the user request or to a get with the method property value submitted as a request. About method= "get" specific
See the example. QueryString retrieves the value of the HTTP query string variable, and the HTTP query string has the value set after the question mark. Often used for page jumps,
The pass of the parameter. Specific code show:
protected void Btnok_click (object sender, EventArgs e)
{
Response.Redirect ("vote_showresult.aspx?voteid=" + This.masterid);
}
Two Response Objects
The response object is used to line the data that the client browser sends the server. The user can use this object to use the server-side data with the HTML grid
Send to the client browser. The function of this object is contrary to the function of the request object, the request object is used to get the data submitted by the user, and
The response object is used to send the server's data to the user's browser, which is the basis for implementing the dynamic effect of the Web page.1 Properties 1) Buffer PropertyIn the ASP.net program, you can set a buffer on the server side of the page. In fact, a buffer is a storage area that can accommodate a period of time before it releases data. After the buffer is set, the server side can reduce the number of connections to the client and increase the speed of the whole, and can undo the processed results when certain conditions are met without a situation where the response is complete. The Beffer property determines that the cache is turned on/off. If False, the cache is turned off, and if true, the cache is turned on. The change of the buffer property must be placed before HTML or script output, because the value of the buffer property cannot be changed after any content is sent to the browser, or it can cause an error. Note: Use the Redirect method to redirect the page anywhere in the ASP.net file, and you must close the Buffer property at the beginning of the file, or you will get an error.2) Status PropertyThe state used to pass the server HTTP response. Can be used to handle HTTP requests after the server returns an error. The server Return status code consists of 3 digits that determine how the server handles HTTP requests based on the status code. The Status property is important in the debugging process or when you return related errors to the client, and you can specify the source of the error based on the status code. Another: A very full state code http://blog.sina.com.cn/s/blog_4ae187490100x9u7.html
3) IsClientConnected PropertyIt is a read-only property that indicates whether the client is connected to the server after the last call to Response.Write. This property allows the user to have more control over the client without a connection to the server. For example2 Method 1) WriteIt is one of the most commonly used methods in the Reponse object, and it can send the value of a variable to the client's current page, which almost and one outputs all the objects and data. You can embed any HTML tag in the Write method, as long as the tag is legitimate.2) ClearClear clears all HTML output from the buffer, but it only deletes the corresponding text and does not delete the title. When a program on the server generates an error, the Clear method is available to handle the error condition. Note: The Clear method only works if the response object's Buffer property is set to true. If the buffer property is not set to true, the clear method causes a run error.3) EndThe end method causes the server to stop processing of the current script and return the current result. If the response object's buffer is set to true, the end method immediately sends the contents of the cache to the client and clears the cache. Therefore, if you want to cancel all output to the client, you can use the clear method to purge the cache, and then use the End method to stop the processing of the script.4) Redirect
In a normal Web page, you can use hyperlinks to boot me to another page, but this process requires a visitor to click a hyperlink. The redirect method of the Response object automatically completes the jump between pages, and the visitor can hardly feel it. Summary:
The response object is used to receive data submitted by the client browser, and the request object's function is to send the server-side data to the client browser.