SessionAuthenticationModule.SessionSecurityTokenCreated イベント

定義

セッション セキュリティ トークンが作成されたときに発生します。

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) 

イベントの種類

次のコードは、ASP.NET Web アプリケーションのglobal.asax.cs ファイルに実装されたイベントのハンドラー SessionSecurityTokenCreated を示しています。 イベントにハンドラーを追加する必要もあります。 より完全な例については、概要に関するトピックを SessionAuthenticationModule 参照してください。

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;
}

注釈

このイベントを使用して、セッション セキュリティ トークンを Cookie に書き込む前に変更できます。

イベントはSessionSecurityTokenCreated、セッション トークン (SessionSecurityToken) がOnAuthenticateRequest作成された後、 メソッド内から発生します。 これは、たとえば、イベントのイベント ハンドラーによってトークンが SessionSecurityTokenReceived 変更された場合に発生します。

このイベントを使用して、パイプラインに沿ってさらに渡される前にセッション トークンのプロパティを変更し、要求を行うエンティティ (ユーザー) を認証するために使用できます。

イベント ハンドラーでは、 プロパティを使用してトークンに SessionSecurityTokenCreatedEventArgs.SessionToken アクセスできます。 トークンを変更した後、 プロパティを に設定 SessionSecurityTokenCreatedEventArgs.WriteSessionCookie することで、トークンが Cookie に確実に true書き戻されるようにすることができます。 とは異なり、 SessionSecurityTokenCreated イベント SessionSecurityTokenCreated は取り消し可能なイベントではありません。

適用対象