WSFederationAuthenticationModule.RedirectingToIdentityProvider 事件

定义

当模块即将重定向用户标识提供程序时发生。Occurs when the module is going to redirect the user to the identity provider.

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

事件类型

EventHandler<RedirectingToIdentityProviderEventArgs>

示例

下面的代码演示如何 RedirectingToIdentityProvider 在 global.asax 文件中的事件中为事件添加处理程序 Application_InitThe following code shows how to add a handler for the RedirectingToIdentityProvider event in the Application_Init event in the global.asax file. 此代码取自 FederationForWebApps 示例。The code is taken from the FederationForWebApps sample. 有关此示例的详细信息,请参阅WIF 代码示例索引For more information about this sample, see WIF Code Sample Index.

下面的代码演示了 RedirectingToIdentityProvider RP 的 global.asa 文件中的事件的处理程序。The following code shows the handler for the RedirectingToIdentityProvider event in the in the global.asax file of an RP. 该代码将检查传入的 HTTP 请求是否包含一个 $ 零参数,如果它存在,则将此参数设置为要发送到 STS 的 WS 联合身份验证登录请求。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. 此代码取自 FederationForWebApps 示例。The code is taken from the FederationForWebApps sample. 有关此示例的详细信息,请参阅WIF 代码示例索引For more information about this sample, see WIF Code Sample Index.

下面的代码显示 RedirectingToIdentityProvider 联合身份验证提供程序 STS 的 global.asa 文件中的事件的处理程序。The following code shows the handler for the RedirectingToIdentityProvider event in the in the global.asax file of a federation provider STS. 代码会检查传入的 HTTP 请求是否包含一个里瓦的参数。The code checks to see whether the incoming HTTP request contains a whr parameter. 如果请求包含瓦时参数,则会将客户端定向到用于登录的 IP-STS;如果不是,则会将客户端定向到 "主领域发现" 页,以选择要登录的 IP-STS。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. 此代码取自 FederationForWebApps 示例。The code is taken from the FederationForWebApps sample. 有关此示例的详细信息,请参阅WIF 代码示例索引For more information about this sample, see WIF Code Sample Index.

注解

你可以通过属性访问和修改 WS 联合身份验证登录请求 RedirectingToIdentityProviderEventArgs.SignInRequestMessageYou can access and modify the WS-Federation sign-in request through the RedirectingToIdentityProviderEventArgs.SignInRequestMessage property. 例如,你可以修改 BaseUri 登录消息中的属性,以更改将请求重定向到的标识提供者。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. RedirectingToIdentityProvider事件为可取消的事件,你可以将 Cancel 属性设置为, true 以取消重定向。The RedirectingToIdentityProvider event is a cancelable event and you can set the Cancel property to true to cancel the redirect.

通过调用方法,从方法内部引发事件 RedirectToIdentityProvider OnRedirectingToIdentityProviderThe event is raised from inside the RedirectToIdentityProvider method through a call to the OnRedirectingToIdentityProvider method.

若要在 ASP.NET 应用程序中处理此事件,请 WSFederationAuthentication_RedirectingToIdentityProvider 在 global.asax 文件中创建一个名为的方法。To handle this event in an ASP.NET application, create a method called WSFederationAuthentication_RedirectingToIdentityProvider in the global.asax file.

适用于