Page..::.Session Property
This page is specific to:.NET Framework Version:
.NET Framework Class Library
Page..::.Session Property

Gets the current Session object provided by ASP.NET.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Syntax

'Usage

Dim instance As Page
Dim value As HttpSessionState

value = instance.Session


'Declaration

<BrowsableAttribute(False)> _
Public Overridable ReadOnly Property Session As HttpSessionState

Property Value

Type: System.Web.SessionState..::.HttpSessionState
The current session-state data.
Exceptions

ExceptionCondition
HttpException

Occurs when the session information is set to nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

This property provides information about the current request's session. A Session object is maintained for each user that requests a page or document from an ASP.NET application. Variables stored in the Session object are not discarded when the user moves from page to page in the application; instead, these variables persist as long as the user is accessing pages in your application. For more information about session state, see ASP.NET Session State Overview.

TopicLocation
How to: Read Values from Session StateBuilding ASP .NET Web Applications
How to: Read Values from Session StateBuilding ASP .NET Web Applications
How to: Read Values from Session StateBuilding ASP .NET Web Applications in Visual Studio
How to: Read Values from Session StateBuilding ASP .NET Web Applications in Visual Studio
How to: Sample Session-State Store ProviderBuilding ASP .NET Web Applications
How to: Sample Session-State Store ProviderBuilding ASP .NET Web Applications
How to: Sample Session-State Store ProviderBuilding ASP .NET Web Applications in Visual Studio
How to: Sample Session-State Store ProviderBuilding ASP .NET Web Applications in Visual Studio
How to: Save Values in Session StateBuilding ASP .NET Web Applications
How to: Save Values in Session StateBuilding ASP .NET Web Applications
How to: Save Values in Session StateBuilding ASP .NET Web Applications in Visual Studio
How to: Save Values in Session StateBuilding ASP .NET Web Applications in Visual Studio
Examples

The following code example creates a GetStyle function that retrieves a key stored in the session state of the Web Forms page and converts its value to a string.

' 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


Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View