Page.Session Proprietà

Definizione

Ottiene l'oggetto corrente Session fornito da 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

Valore della proprietà

Dati dello stato sessione correnti.

Attributi

Eccezioni

Si verifica quando le informazioni sulla sessione sono impostate su null.

Esempio

Nell'esempio di codice seguente viene creata una GetStyle funzione che recupera una chiave archiviata nello stato della sessione della pagina Web Form e ne converte il valore in una stringa.

// 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

Commenti

Questa proprietà fornisce informazioni sulla sessione della richiesta corrente. Un oggetto Session viene mantenuto per ogni utente che richiede una pagina o un documento da un'applicazione ASP.NET. Le variabili archiviate nell'oggetto Session non vengono eliminate quando l'utente passa dalla pagina alla pagina nell'applicazione. Queste variabili vengono mantenute purché l'utente acceda alle pagine nell'applicazione. Per altre informazioni sullo stato della sessione, vedere ASP.NET Panoramica dello stato sessione.

Si applica a

Vedi anche