RedirectingToIdentityProvider Event

WSFederationAuthenticationModule.RedirectingToIdentityProvider Event

.NET Framework (current version)
 

Occurs when the module is going to redirect the user to the identity provider.

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

public event EventHandler<RedirectingToIdentityProviderEventArgs> RedirectingToIdentityProvider

You can access and modify the WS-Federation sign-in request through the RedirectingToIdentityProviderEventArgs.SignInRequestMessage property. For example, you can modify the BaseUri property in the sign-in message to change the identity provider to which the request will be redirected. The RedirectingToIdentityProvider event is a cancelable event and you can set the Cancel property to true to cancel the redirect.

The event is raised from inside the RedirectToIdentityProvider method through a call to the OnRedirectingToIdentityProvider method.

To handle this event in an ASP.NET application, create a method called WSFederationAuthentication_RedirectingToIdentityProvider in the global.asax file.

The following code shows how to add a handler for the RedirectingToIdentityProvider event in the Application_Init event in the global.asax file. The code is taken from the FederationForWebApps sample. For more information about this sample, see WIF Code Sample Index.

The following code shows the handler for the RedirectingToIdentityProvider event in the in the global.asax file of an RP. The code checks to see whether the incoming HTTP request contains a whr parameter, and, if it does, it sets this parameter on the WS-Federation sign-in request that will be sent to the STS. The code is taken from the FederationForWebApps sample. For more information about this sample, see WIF Code Sample Index.

The following code shows the handler for the RedirectingToIdentityProvider event in the in the global.asax file of a federation provider STS. The code checks to see whether the incoming HTTP request contains a whr parameter. If the request contains the whr parameter, the client is directed to the IP-STS for sign-in; if not, the client is directed to a home realm discovery page to select the IP-STS at which to sign in. The code is taken from the FederationForWebApps sample. For more information about this sample, see WIF Code Sample Index.

.NET Framework
Available since 4.5
Return to top
Show:
© 2016 Microsoft