Session object, application object, and viewstate object are important objects of ASP. NET. They can be used to save application data or cache webpage data. However, they still have the following differences.
1. The session object and Application object are global. After the entire application is running, the program can access the session object and Application object at any time; after a viewstate object is assigned a value on a specific page, when the page is closed, other pages of the application cannot use the corresponding value of the viewstate object.
2. The session object is exclusive to one user, not shared by all users accessing the site. Each access user has its own unique sessionid, and the session object is always valid before the application. It is functionally similar to static variables. The viewstate object can be seen as a local variable of a page.
3. The application object is shared by all users on the site. Each access user can access the application object. In the development of some common forums, you can use the application object to count the number of online user visits, and use the session object to count the total number of visits.
4. The extensive use of viewstate objects can increase the overhead of applications. If you need to consider program efficiency, be especially careful when using viewstate objects.