Objects that store state on the server: Session and Application
Objects in the client store state: Cookies
1.Session: Each independent browser will create a separate session, not a computer a session
Session stored data is shared in the current session, and closing sessions disappears
Features: Session within 20 minutes if there is no session operation, it will be automatically released
Syntax: (1) Use the Session value: session["key Name"] = value; Value, which is not just a string, it can be an object.
(2) value from Session: type variable name = (cast type name) session["key Name"]
(3) Release Session: Release a session:session["key name"]=NULL;
Release all Session:Session.clear ();
Automatic release: 20 minutes
2. Cookies: Protect client memory or hard disk
A temporary cookie is present in the browser memory and persistent cookie is present in the browser-related cookie directory on the computer's hard disk.
Set cookies
New Cookie Object
HttpCookie cookie_name = new HttpCookie ("UID");
Assign value
Cookie_name. Value = UID;
Write to Cookie Inside
Response.appendcookie (Cookie_name);
In use interface: Read cookie
request.cookies["UID"]. Value.tostring ();
5.QueryString Transmit Value
Write on the source page: Response.Redirect ("main.aspx" (the page to open) uid= "+uid+" &pwd= "+pwd (to transfer past values);//Pass the value over when opening a new page
On the target page: request["UID"]. ToString ();
7. Jump Page Mode:
1.response.redirect ("http://www.baidu.com"); Redirect to jump to any page
2.server.transfer ("main.aspx"); You can only jump to sites in the root directory of the site
"ADO." NET Foundation-session "Session Basic Application