为什么以及何时使用视图状态会话和应用程序状态 [英] why and when to use view state session and application state

查看:89
本文介绍了为什么以及何时使用视图状态会话和应用程序状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我为什么以及何时在asp .net中使用会话视图状态和应用程序状态

Please tell me why and when to use session view state and application state in asp .net

推荐答案

首先,我将从MSDN为您提供以下定义:



会话:会话变量存储在通过HttpContext.Session属性公开的SessionStateItemCollection对象中。在ASP.NET页面中,当前会话变量通过Page对象的Session属性公开。



关于会话的更多信息:http://msdn.microsoft.com/en-us/library/ms178581(v=vs.100)。 aspx [ ^ ]





ViewState:Microsoft®ASP.NET视图状态,简而言之,是ASP.NET网页用于跨回发持久更改Web表单状态的技术。



关于Viewstate的更多信息:http://msdn.microsoft.com/en-us/library/ms972976.aspx [ ^ ]





应用程序:您可以将Application对象用于shar给定应用程序的所有用户之间的信息。基于ASP的应用程序定义为虚拟目录及其子目录中的所有.asp文件。由于Application对象可以由多个用户共享,因此可以使用Lock和Unlock方法来确保多个用户不会尝试同时更改属性。



关于应用程序的更多信息: http://msdn.microsoft.com/en-us/library/ms525360(v = vs.90).aspx [ ^ ]





如何从Viewstate,Session,Application,Cache和Cookies中选择: http://www.articlesbase.com/programming-articles/how-to-choose-from-viewstate-session-application-cache-and-cookies -443393.html

[ ^ ]





Cache,Session和ViewState:缓存,会话和ViewState [ ^ ]





希望这些信息可以帮助你...
First I will provide you the following definitions from MSDN for them:

Session: Session variables are stored in a SessionStateItemCollection object that is exposed through the HttpContext.Session property. In an ASP.NET page, the current session variables are exposed through the Session property of the Page object.

More about Sessions: http://msdn.microsoft.com/en-us/library/ms178581(v=vs.100).aspx[^]


ViewState: Microsoft® ASP.NET view state, in a nutshell, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks.

More about Viewstate: http://msdn.microsoft.com/en-us/library/ms972976.aspx[^]


Application: You can use the Application object to share information among all users of a given application. An ASP-based application is defined as all the .asp files in a virtual directory and its subdirectories. Because the Application object can be shared by more than one user, there are Lock and Unlock methods to ensure that multiple users do not try to alter a property simultaneously.

More about Application: http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx[^]


How to Choose From Viewstate, Session, Application, Cache, and Cookies: http://www.articlesbase.com/programming-articles/how-to-choose-from-viewstate-session-application-cache-and-cookies-443393.html
[^]


Cache, Session, and ViewState: Cache, Session, and ViewState[^]


Hope this information helps you...


这篇关于为什么以及何时使用视图状态会话和应用程序状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆