Page.Session Właściwość

Definicja

Pobiera bieżący Session obiekt dostarczony przez ASP.NET.

public:
 virtual property System::Web::SessionState::HttpSessionState ^ Session { System::Web::SessionState::HttpSessionState ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual System.Web.SessionState.HttpSessionState Session { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Session : System.Web.SessionState.HttpSessionState
Public Overridable ReadOnly Property Session As HttpSessionState

Wartość właściwości

HttpSessionState

Bieżące dane stanu sesji.

Atrybuty

Wyjątki

Występuje, gdy informacje o sesji są ustawione na null.

Przykłady

Poniższy przykład kodu tworzy GetStyle funkcję, która pobiera klucz przechowywany w stanie sesji strony Web Forms i konwertuje jego wartość na ciąg.

// 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();       
}
' 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

Uwagi

Ta właściwość zawiera informacje o sesji bieżącego żądania. Obiekt Session jest utrzymywany dla każdego użytkownika, który żąda strony lub dokumentu z aplikacji ASP.NET. Zmienne przechowywane w Session obiekcie nie są odrzucane, gdy użytkownik przechodzi ze strony do strony w aplikacji. Zamiast tego te zmienne są utrwalane tak długo, jak użytkownik uzyskuje dostęp do stron w aplikacji. Aby uzyskać więcej informacji na temat stanu sesji, zobacz ASP.NET Omówienie stanu sesji.

Dotyczy

Zobacz też