SessionAuthenticationModule.SessionSecurityTokenCreated Zdarzenie

Definicja

Występuje po utworzeniu tokenu zabezpieczającego sesji.

public:
 event EventHandler<System::IdentityModel::Services::SessionSecurityTokenCreatedEventArgs ^> ^ SessionSecurityTokenCreated;
public event EventHandler<System.IdentityModel.Services.SessionSecurityTokenCreatedEventArgs> SessionSecurityTokenCreated;
member this.SessionSecurityTokenCreated : EventHandler<System.IdentityModel.Services.SessionSecurityTokenCreatedEventArgs> 
Public Custom Event SessionSecurityTokenCreated As EventHandler(Of SessionSecurityTokenCreatedEventArgs) 
Public Event SessionSecurityTokenCreated As EventHandler(Of SessionSecurityTokenCreatedEventArgs) 

Typ zdarzenia

Przykłady

Poniższy kod przedstawia procedurę obsługi SessionSecurityTokenCreated zdarzenia zaimplementowanego w pliku global.asax.cs aplikacji internetowej ASP.NET. Należy również dodać procedurę obsługi do zdarzenia. Bardziej kompletny przykład pokazano w temacie SessionAuthenticationModule przeglądu.

void SessionAuthenticationModule_SessionSecurityTokenCreated(object sender, SessionSecurityTokenCreatedEventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SessionSecurityTokenCreated event");
    //Store session on the server-side token cache instead writing the whole token to the cookie.
    //It may improve throughput but introduces server affinity that may affect scalability
    FederatedAuthentication.SessionAuthenticationModule.IsReferenceMode = true;
}

Uwagi

To zdarzenie służy do modyfikowania tokenu zabezpieczającego sesji przed zapisaniem go w pliku cookie.

Zdarzenie SessionSecurityTokenCreated jest wywoływane z metody po utworzeniu OnAuthenticateRequest tokenu sesji (SessionSecurityToken). Dzieje się tak na przykład, jeśli program obsługi zdarzeń dla SessionSecurityTokenReceived zdarzenia modyfikuje token.

To zdarzenie służy do modyfikowania właściwości tokenu sesji przed przekazaniem go dalej wzdłuż potoku i służy do uwierzytelniania jednostki wysyłającej żądanie (użytkownika).

W procedurze obsługi zdarzeń można uzyskać dostęp do tokenu SessionSecurityTokenCreatedEventArgs.SessionToken za pośrednictwem właściwości . Po zmodyfikowaniu tokenu możesz upewnić się, że jest zapisywany z powrotem do pliku cookie, ustawiając SessionSecurityTokenCreatedEventArgs.WriteSessionCookie właściwość na true. SessionSecurityTokenCreated W przeciwieństwie do zdarzenia nie SessionSecurityTokenCreated jest to zdarzenie, które można anulować.

Dotyczy