Cookie basics in ASP. NET

Source: Internet
Author: User
Tags sha1 encryption

In ASP. NET, what is the basic Cookie knowledge? What do I need to know about Cookie programming in ASP. NET? First, let's take a look at the meaning of cookies in ASP. NET.

Cookies in ASP. NET provide a useful method for Web applications to save user-related information. For example, when a user accesses your site, you can use cookies to save user preferences or other information, so that when the user visits your site next time, the application can retrieve previously saved information.

This article describes the application of cookies in ASP. NET applications. It shows you the technical details of Cookie application in ASP. NET, such as compiling cookies and then reading them. In addition, we will introduce you to various features and special circumstances of cookies, as well as ASP. NET's support for cookies.

What is a Cookie in ASP. NET?

ASP. NET cookies are short text messages that are transmitted between the Web server and the browser as user requests and pages. Each time a user accesses a site, the Web application can read the information contained in the Cookie.

Assume that when a user requests to access a page on your website, your application sends not only a page to the user, but also a Cookie containing the date and time. The user's browser obtains the Cookie while obtaining the page, and saves it in a folder on the user's hard disk.

Later, if the user visits the page on your site again, when the user enters the URL, the browser will find the Cookie associated with the URL on the local hard disk. If the Cookie exists, the browser sends it along with the page request to your site, and your application can determine the date and time of the user's last visit to the site. You can send a message to the user based on this information, or check the expiration time or perform other useful functions.

The Cookie in ASP. NET is associated with a Web site rather than a specific page. Therefore, no matter which page the user requests to browse the site, the browser and server will exchange the Cookie information. When a user accesses other sites, each site may send a Cookie to the user's browser, and the browser will save all these cookies separately.

These are the basic operating principles of cookies. So what are the functions of cookies? The most fundamental purpose is that cookies can help websites save information about visitors. To put it more simply, Cookie is a way to maintain the continuity of Web applications, that is, to execute "state management. The browser and the Web server are always disconnected except for a short period of actual information exchange, and each request sent by the user to the Web server is processed independently, regardless of all other requests. However, in most cases, it is necessary for the Web server to identify you when you request a page. For example, a Web server on a shopping site tracks each shopper so that the site can manage shopping cart and other user-related information. Therefore, the Cookie function is similar to a business card. It provides the relevant identification information to help the application determine how to proceed.

The use of cookies in ASP. NET can achieve multiple purposes, all of which are to make the Web site remember you. For example, a site that implements a public opinion test can simply use cookies as a Boolean value to indicate whether your browser has participated in the vote, thus avoiding repeated voting; websites that require user login can use cookies to determine whether you have logged on, so that you do not have to enter creden。 every time.

The basic information about cookies in ASP. NET is introduced to you so much. I hope these will help you learn about cookies in ASP. NET.

  1. Examples of ASP. NET File Upload controls
  2. Nine steps for learning ASP. NET
  3. Advantages of ASP. NET compared with ASP
  4. Analysis of ASP. NET MD5 and SHA1 encryption methods
  5. ASP. NET learning-CSS implementation multi-interface two methods

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.