Export (0) Print
Expand All

HttpContext.Session Property

Gets the HttpSessionState instance for the current HTTP request.

[Visual Basic]
Public ReadOnly Property Session As HttpSessionState
[C#]
public HttpSessionState Session {get;}
[C++]
public: __property HttpSessionState* get_Session();
[JScript]
public function get Session() : HttpSessionState;

Property Value

The HttpSessionState object for the current HTTP request.

Remarks

The HttpContext.Session property provides programmatic access to the properties and methods of the HttpSessionState class. Because ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext. For example, you can use just Session("SessionVariable1") to get or set the value of the session state variable SessionVariable1. If you want to use the members of HttpResponse from an ASP.NET code-behind module, however, you must include a reference to the System.Web namespace in the module and also fully qualify the reference to the currently active request/response context and the class in System.Web you want to use. For example, in a code-behind page you must specify the full name HttpContext.Current.Session("SessionVariable1").

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpContext Class | HttpContext Members | System.Web Namespace

Show:
© 2014 Microsoft