OnSignedOutCallbackRedirect

OnSignedOutCallbackRedirect

本文介绍了post_logout_redirect_uri ASP NET Core 2.2 AzureAD Razor 类库 RCL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经尝试使用示例https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/浏览了样本和所有作品.在注销过程后,我们无法让它重定向.此外,似乎帐户控制器不存在,但它在 _layout.chtml 中被调用,这一定是新的.

解决方案

您可以通过设置 OnSignedOutCallbackRedirect 事件将用户重定向到另一个页面:

  1. Startup.cs中添加using System.Threading.Tasks;
  2. OnSignedOutCallbackRedirect 事件中配置您的新重定向网址:

    services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>{options.Authority = options.Authority + "/v2.0/";options.TokenValidationParameters.ValidateIssuer = false;options.Events.OnSignedOutCallbackRedirect = (上下文) =>{context.Response.Redirect("/Home/About");context.HandleResponse();返回Task.CompletedTask;};});

We have tried using the samplehttps://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/Walked through the sample and all works.We can't get it to redirect after logout process. Also, it seems the account controller is not there but it is called in _layout.chtml this must be something new.

解决方案

You can redirect user to another page after sign-out by setting the OnSignedOutCallbackRedirect event :

  1. In Startup.cs add using System.Threading.Tasks;
  2. Config your new redirect url in OnSignedOutCallbackRedirect event :

    services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
    {
        options.Authority = options.Authority + "/v2.0/";
    
        options.TokenValidationParameters.ValidateIssuer = false;
    
        options.Events.OnSignedOutCallbackRedirect = (context) =>
        {
    
            context.Response.Redirect("/Home/About");
            context.HandleResponse();
    
            return Task.CompletedTask;
        };
    });
    

这篇关于post_logout_redirect_uri ASP NET Core 2.2 AzureAD Razor 类库 RCL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 00:38