Saving status data in ASP. NET

Source: Internet
Author: User
The Web is stateless. If you need to save the status, you need to use some technologies.
1. cookie
Store a small amount of data, and the value of continuous access to the same site can remain unchanged.
2. session
It can store big data but also relies on cookies.
You can select cookieless session for the session, and the sessionID will be written in the URL, so it does not depend on the cookie.
Based on the storage location, external sessions based on windows Services can be used and stored in independent processes or SQL Server databases.
The windows Service is ASP. NET State Service.
You can set the session attribute in the config file.
For example:
<Configuration>
<System. web>
<Sessionstate
Mode = "StateServer"
StateConnectionString = "tcpip = 192.168.0.1: 42424"
Cookieless = "false"
Timeout = "20"
/>
</System. web>
</Configuration>
3. Application
Shared by all users
4. cache
All users share (similar to Application ). Cache can use some expiration policies.
Access through HttpContext or page. cache.

5. Static variables
Global access to the entire application, which is more efficient than application
Create a new class and define a public static in this class.
6. viewstate
7. profile
8. hidden

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.