Asp. The advantages and disadvantages of net client state management method

Source: Internet
Author: User

In general, the HTTP protocol is a stateless service, and it does not save any user request information. Web applications have been greatly developed until Netscape began using cookies to save user request information. Now asp.net programmers can save user request information in a number of ways.

Here are a few ways to ASP.net about client state management.

asp.net, which provides cookies, querystrings (URL), Hidden fields, View State and control state (ASP.net 2.0), manages client requests.

A, Cookie

Cookies are stored as text on your computer, using name-value matching. General user stores identify user information, such as user name, user Configuration, and so on. Although cookies can be stored encrypted, it is not recommended to save user passwords in cookies. Second, the size of the cookie is limited, so it is not appropriate to store large data.

Example:

1. Get User ID

if (request.cookies["UserId"]!= null)
Lbmessage.text = "Dear" + request.cookies["UserId"]. Value + ", Welcome to our website!";
else
Lbmessage.text = "Guest,welcome to our website!";

2. Set Cookies

response.cookies["UserId"]. Value=username;

Advantages:

Easy to use

Disadvantages:

1, the client can disable cookies

2, the cookie will be loaded every time the request or send, affect transmission.

3, easy to be breached, all not suitable for storing security information.

Related Article

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.