Introduction to the use of Asp.ne response objects and request objects

Source: Internet
Author: User

  This article mainly introduces the Asp.ne response object and request object use, the need for friends can refer to the following

1.Response: The server sends the client information, or the server transmits the output to the user.     Redirect: Let the client redirect to the specified URL.     Write: Writes out the specified string.     2.request: The client sends the server, or obtains the information from the client.     FORM: Gets the value of a form element from a form that uses the Post submission method.     QueryString: Retrieve the variable value from the query string and apply it to the form of get submit.     Take an example: a landing page, there is a main page. When the landing page is successful, it automatically jumps to the main page.     1.login.aspx    code as follows: <form id= "Form1" runat= "Server" method= "POST" >  <div>& nbsp <div>  <asp:label id= "Lbluser" runat= "server" text= "username" ></asp:Label>  <asp:textbox Id= "Txtuser" runat= "Server" ></asp:TextBox>  </div>  <div></div>  <div >  <asp:label id= "lblpwd" runat= "server" text= "password" ></asp:Label>  <asp:textbox id= "Txtpwd" "runat=" server ></asp:TextBox>  </div>  <div>  <asp:button id= "Button1" runat= "Server" text= "login" onclick= "button1_click" style= "width:40px"/>  </div>  </div>&nbsp </form>    login.aspx.cs  code is as follows: protected void Button1_Click (object sender, EventArgs e)   {& nbsp String user = Request.Form.Get ("Txtuser"). ToString ()//The client sends the server a user name   string pwd = Request.Form.Get ("Txtpwd") to be submitted. ToString (); Client to the server need to submit the password   if (user = = "1" && pwd = = "1")   {  Response.Redirect ("main.aspx?user=" + user); Jump to Main page  }  else  {  Response.Write ("Login Failed"); }    2.main.aspx.cs    code as follows : protected void Page_Load (object sender, EventArgs e)   {  string user = request.querystring["user"]. ToString ();//Get user username   Response.Write ("Welcome + user + Login"); }    When the login page obtains the correct username and password, the password will be redirected to the main page. The home page also prompts for a successful login. When you enter an error, you will be prompted for a login failure.     in Beef brisket press release system, these two objects will often be used, I believe that in future learning will be used more, understanding will be more profound.    

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.