Is the control, nothing to say ...
Response: Response from server-client
Write ("string"): output a paragraph of text to the client page
Redirect ("URL"): redirect
End (): Ends the output to the client
Request: Requests from client--server
request["name"]: Gets the data that the client passes over by post or get.
request.form["name"]: Gets the data that the client passes over by post.
request.querystring["name"]: Gets the data that the client passes over by means of get.
Session: Sessions-used to save visitor status. A session in which the state is saved, which is only available in this session.
Role: The same browser opens the page sub-page, will load the current login user information. Instead of a browser, or a new browser, you will be logged in again.
HTTP: Stateless protocol
Simple login Eg:
Create a new Web page that is designed as follows:
Double-click the Sign In button to write the code:
1 protected voidButton1_Click (Objectsender, EventArgs e)2 {3Mydbdatacontext context =NewMydbdatacontext ();4 varQ = Context. Login.where (P=>p.username==textbox1.text&p.pwd==textbox2.text);//Verify that the user name password is correct5 if(Q.count () >0)6 {7session["UID"] = TextBox1.Text;//session Sessions-Save visitor status8Response.Redirect ("main.aspx?id="+textbox1.text);//REDIRECT to login interface9 }Ten Else One { A //Response.Write ("Username or password error <a href= ' default.aspx ' > Return </a>"); - //Response.End (); -Label1.visible =true;//User name password is displayed incorrectly the } -}
Create a new main main web interface:
1 <Body>2 <formID= "Form1"runat= "Server">3 <Div>4 5Welcome you,<Asp:labelID= "Label1"runat= "Server"Font-bold= "True"Font-underline= "True"ForeColor= "#CC0000"Text= "Label"></Asp:label>6 <ahref= "Main.aspx"Target= "_blank">New Page</a>7 8 </Div>9 </form>Ten </Body>
1 protected voidPage_Load (Objectsender, EventArgs e)2 {3 //Label1.Text = request["id"]. ToString ();4 if(session["UID"] ==NULL)5 {6Response.Redirect ("Default.aspx"); //If you skip the login interface and access the main interface directly, skip to the login screen 7 }8 Else9 {TenLabel1.Text = session["UID"]. ToString (); //Login successful, display user name One } A}
To run the login interface:
2014.12.03 page Control