持续完善 Pinda.cn 秒建营销活动 通过低代码 零代码的模式快速创建营销活动,欢迎使用 。

Page.Session 属性

.NET Framework 类库 
Page.Session 属性 

获取 ASP.NET 提供的当前 Session 对象。

命名空间:System.Web.UI
程序集:System.Web(在 system.web.dll 中)

语法
Visual Basic(声明)
Public Overridable ReadOnly Property Session As HttpSessionState
Visual Basic(用法)
Dim instance As Page
Dim value As HttpSessionState
value = instance.Session
C#
public virtual HttpSessionState Session { get; }
C++
public:
virtual property HttpSessionState^ Session {
HttpSessionState^ get ();
}
J#
/** @property */
public HttpSessionState get_Session ()
JScript
public function get Session () : HttpSessionState

属性值

当前会话状态数据。
异常
异常类型 条件

HttpException

将会话信息设置为 空引用(在 Visual Basic 中为 Nothing) 时发生。

备注

该属性提供有关当前请求的会话的信息。为从 ASP.NET 应用程序请求页或文档的每个用户维护一个 Session 对象。当用户在应用程序中从一页移动到另一页时,存储在 Session 对象中的变量不会被放弃;相反,只要用户在应用程序中访问页,这些变量就将保持。有关会话状态的更多信息,请参见 ASP.NET 会话状态

示例

下面的代码示例创建一个 GetStyle 函数,该函数检索 Web 窗体页会话状态中存储的键,并将其值转换为字符串。

' Create a private function that obtains
' information stored in session state
' in the application's Global.asax file.
' When this method is called and a key name
' that is stored in session state is passed
' as the parameter, the key is obtained and
' converted to a string.
Function GetStyle(Key As String) As String
Return Session(Key).ToString()
End Function
// Create a private function that obtains
// information stored in Session state
// in the application's Global.asax file.
// When this method is called and a key name
// that is stored in Session state is passed
// as the paramter, the key is obtained and
// converted to a string.
String GetStyle(String key) {
return Session[key].ToString();
}
平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0
posted @ 2006-06-03 23:48  工具人Kim哥  阅读(1214)  评论(0)    收藏  举报
持续完善 Pinda.cn 秒建营销活动 通过低代码 零代码的模式快速创建营销活动,欢迎使用 。