"ADO." NET Foundation-session "Session Basic Application

Source: Internet
Author: User

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

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.