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