ASP. Net Cookie implementation

Source: Internet
Author: User

Cookie usage is similar to ASP.

For example, we create a cookie named aspcn with the value of flying knife.
HttpCookie = new HttpCookie ["aspcn"];
Cookie. Value = "Flying knife ";
Response. AppendCookie (cookie );
It's easy to retrieve the Cookie value.
HttpCookie cookie = Request. Cookies ["aspcn"];
CookieValue = cookie. Value;
Sometimes we want to store multiple pieces of information in a Cookie. For example, we add multiple information under the cookie named aspcn.
HttpCookie cookie = new HttpCookie ("aspcn ");
Cookie. Values. Add ("webmaster", "Flying knife ");
Cookie. Values. Add ("writer", "beige ");
Cookie. Values. Add ("LinkColor", "blue ");
Response. AppendCookie (cookie );
Retrieving information is as easy as possible
HttpCookie cookie = Request. Cookies ["aspcn"];
Value1 = cookies. Values ["webmaster"];
Value2 = cookies. Values ["writer"];

View State

This is a new concept. Its usage is the same as Session. Its main purpose is to record the status of Web Control. Although it is new, it is no different from the Application and Session usage, so I don't want to explain it in detail.
State ["DropLoadIndex"] = 0;
The basic usage is as follows. This is useless after it is released, because it only saves the status of the WEB control.


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.