SessionAuthenticationModule.SignOut Method ()

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Signs the current user out and raises the associated events.

Namespace:   System.IdentityModel.Services
Assembly:  System.IdentityModel.Services (in System.IdentityModel.Services.dll)

public virtual void SignOut()

Exception Condition

Invokes the OnSigningOut, DeleteSessionTokenCookie, and OnSignedOut methods to perform sign-out. If an exception occurs, the OnSignOutError method is invoked to raise the SignOutError event. You can set the Cancel property of the ErrorEventArgs object passed into the event handler for this event to cancel the sign-out and prevent the exception from being propagated to the client.

You can override this method to add application-specific behavior.

The following code shows code for invoking the SignOut method from a SignOut.aspx page (SignOut.aspx.cs) in an ASP.NET web application. A more complete example is shown in the SessionAuthenticationModule overview topic.

void Application_Start(object sender, EventArgs e)
    // Code that runs on application startup

    FederatedAuthentication.SessionAuthenticationModule.SessionSecurityTokenCreated += new EventHandler<SessionSecurityTokenCreatedEventArgs>(SessionAuthenticationModule_SessionSecurityTokenCreated);
    FederatedAuthentication.SessionAuthenticationModule.SessionSecurityTokenReceived += new EventHandler<SessionSecurityTokenReceivedEventArgs>(SessionAuthenticationModule_SessionSecurityTokenReceived);
    FederatedAuthentication.SessionAuthenticationModule.SigningOut += new EventHandler<SigningOutEventArgs>(SessionAuthenticationModule_SigningOut);
    FederatedAuthentication.SessionAuthenticationModule.SignedOut += new EventHandler(SessionAuthenticationModule_SignedOut);
    FederatedAuthentication.SessionAuthenticationModule.SignOutError += new EventHandler<ErrorEventArgs>(SessionAuthenticationModule_SignOutError);

.NET Framework
Available since 4.5
Return to top