ViewState,Application和Page Session有什么区别?

时间:2021-04-23 20:11:03

Please anyone explain me the difference between ViewState,Application and Session of a Page ?

请有人解释一下ViewState,应用程序和页面会话之间的区别吗?

5 个解决方案

#1


Quick one liners - if you want more detail, just ask

快速一个衬里 - 如果你想要更多细节,请问

ViewState is the variable that holds the current state of the page, which is held in a hidden field in the page (used frequently)

ViewState是保存页面当前状态的变量,它保存在页面的隐藏字段中(经常使用)

ApplicationState is a variable you can store values in during the life off the application (may get cycled periodically, and without your knowledge) (used less-frequently)

ApplicationState是一个变量,您可以在应用程序的生命周期中存储值(可能会定期循环,并且在您不知情的情况下)(使用频率较低)

Session is the variable you can write to that will persist from the moment they hit your site until they close the browser. (barring any timeouts). (used frequently)

Session是您可以写入的变量,从它们访问您的站点到关闭浏览器之前一直存在。 (除非有任何超时)。 (经常使用)

#2


A great article : How to Choose From Viewstate, Session, Application, Cache, and Cookies

一篇好文章:如何从视图状态,会话,应用程序,缓存和Cookie中进行选择

Some good discussion about the difference between Session and Viewstate : Session Vs ViewState

关于Session和Viewstate之间区别的一些很好的讨论:Session Vs ViewState

#3


Session state is saved on the server. Session state is usually cleared after a period of inactivity from the user. Can be persisted in memory, which makes it a fast solution. Which means state cannot be shared in the Web Farm/Web Garden. Can be persisted in a Database, useful for Web Farms / Web Gardens. Is Cleared when the session dies - usually after 20min of inactivity.

会话状态保存在服务器上。会话状态通常在用户不活动一段时间后被清除。可以持久存储在内存中,这使其成为一种快速解决方案。这意味着无法在Web场/ Web园*享状态。可以保存在数据库中,对Web Farms / Web Gardens很有用。在会话终止时清除 - 通常在不活动20分钟后清除。

ViewState is saved in the page. The view state is posted on subsequent post back in a hidden field. Is sent back and forth between the server and client, taking up bandwidth. Has no expiration date. Is useful in a Web Farm / Web Garden

ViewState保存在页面中。视图状态在后续帖子中发布在隐藏字段中。在服务器和客户端之间来回发送,占用带宽。没有失效日期。在Web场/ Web园中很有用

#4


SESSION Variables are stored on the server, can hold any type of data including references, they are similar to global variables in a windows application and use HTTP cookies to store a key with which to locate user's session variables.

SESSION变量存储在服务器上,可以包含任何类型的数据,包括引用,它们类似于Windows应用程序中的全局变量,并使用HTTP cookie存储用于定位用户会话变量的键。

VIEWSTATE Variables are stored in the browser (not as cookies) but in a hidden field in the browser. Also Viewstate can hold only string data or serializable objects.

VIEWSTATE变量存储在浏览器中(而不是cookie),但存储在浏览器的隐藏字段中。 Viewstate也只能保存字符串数据或可序列化对象。

#5


When we use view state to design a web application it retains it's state consistently, in it's current position. If we use session then it does not retain it's state, so when we refresh the browser it starts from the initial page.

当我们使用视图状态来设计Web应用程序时,它会保持其状态一致,保持在当前位置。如果我们使用session,那么它不会保留它的状态,所以当我们刷新浏览器时它会从初始页面开始。

#1


Quick one liners - if you want more detail, just ask

快速一个衬里 - 如果你想要更多细节,请问

ViewState is the variable that holds the current state of the page, which is held in a hidden field in the page (used frequently)

ViewState是保存页面当前状态的变量,它保存在页面的隐藏字段中(经常使用)

ApplicationState is a variable you can store values in during the life off the application (may get cycled periodically, and without your knowledge) (used less-frequently)

ApplicationState是一个变量,您可以在应用程序的生命周期中存储值(可能会定期循环,并且在您不知情的情况下)(使用频率较低)

Session is the variable you can write to that will persist from the moment they hit your site until they close the browser. (barring any timeouts). (used frequently)

Session是您可以写入的变量,从它们访问您的站点到关闭浏览器之前一直存在。 (除非有任何超时)。 (经常使用)

#2


A great article : How to Choose From Viewstate, Session, Application, Cache, and Cookies

一篇好文章:如何从视图状态,会话,应用程序,缓存和Cookie中进行选择

Some good discussion about the difference between Session and Viewstate : Session Vs ViewState

关于Session和Viewstate之间区别的一些很好的讨论:Session Vs ViewState

#3


Session state is saved on the server. Session state is usually cleared after a period of inactivity from the user. Can be persisted in memory, which makes it a fast solution. Which means state cannot be shared in the Web Farm/Web Garden. Can be persisted in a Database, useful for Web Farms / Web Gardens. Is Cleared when the session dies - usually after 20min of inactivity.

会话状态保存在服务器上。会话状态通常在用户不活动一段时间后被清除。可以持久存储在内存中,这使其成为一种快速解决方案。这意味着无法在Web场/ Web园*享状态。可以保存在数据库中,对Web Farms / Web Gardens很有用。在会话终止时清除 - 通常在不活动20分钟后清除。

ViewState is saved in the page. The view state is posted on subsequent post back in a hidden field. Is sent back and forth between the server and client, taking up bandwidth. Has no expiration date. Is useful in a Web Farm / Web Garden

ViewState保存在页面中。视图状态在后续帖子中发布在隐藏字段中。在服务器和客户端之间来回发送,占用带宽。没有失效日期。在Web场/ Web园中很有用

#4


SESSION Variables are stored on the server, can hold any type of data including references, they are similar to global variables in a windows application and use HTTP cookies to store a key with which to locate user's session variables.

SESSION变量存储在服务器上,可以包含任何类型的数据,包括引用,它们类似于Windows应用程序中的全局变量,并使用HTTP cookie存储用于定位用户会话变量的键。

VIEWSTATE Variables are stored in the browser (not as cookies) but in a hidden field in the browser. Also Viewstate can hold only string data or serializable objects.

VIEWSTATE变量存储在浏览器中(而不是cookie),但存储在浏览器的隐藏字段中。 Viewstate也只能保存字符串数据或可序列化对象。

#5


When we use view state to design a web application it retains it's state consistently, in it's current position. If we use session then it does not retain it's state, so when we refresh the browser it starts from the initial page.

当我们使用视图状态来设计Web应用程序时,它会保持其状态一致,保持在当前位置。如果我们使用session,那么它不会保留它的状态,所以当我们刷新浏览器时它会从初始页面开始。