azure-active-directory - Azure AD 登录后如何重定向到特定页面?

标签 azure-active-directory

我正在我的应用程序中集成 Azure AD 登录。我想在成功登录 azure 广告后重定向到特定操作。我的 Startup.Auth.cs 文件中有以下代码。但它没有重定向到redirecturi。任何人都可以建议我如何在成功登录后重定向到自定义页面。

public static void ConfigureAuth(IAppBuilder app)
        {
            app.UseKentorOwinCookieSaver();
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
                {
                    ClientId = clientId,
                    Authority = authority,
                    PostLogoutRedirectUri = postLogoutRedirectUri,
                    RedirectUri = redirectUri,
                    Notifications = new OpenIdConnectAuthenticationNotifications
                    {
                        SecurityTokenValidated = context =>
                        {
                            context.Response.Redirect("/members/logon");
                            return Task.FromResult(0);
                        },
                        AuthenticationFailed = context =>
                        {
                            if (context.Exception.Message.StartsWith("OICE_20004") || context.Exception.Message.Contains("IDX10311"))
                            {
                                context.SkipToNextMiddleware();
                                context.Response.Redirect("/members/logon");
                                return Task.FromResult(0);
                            }

                            return Task.FromResult(0);
                        }
                    }
                });
        }

谢谢,

最佳答案

how to redirect to a custom page after successful login



在 AccountController 中,尝试修改回调重定向 url:
    public void SignIn()
    {
        // Send an OpenID Connect sign-in request.
        if (!Request.IsAuthenticated)
        {
            HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/home/about" }, OpenIdConnectAuthenticationDefaults.AuthenticationType);
        }
    }

使用/controllerName/actionName 。在 OWIN 检查 token 并提取必要的详细信息后,用户将被重定向到您指定的 URL。

关于azure-active-directory - Azure AD 登录后如何重定向到特定页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43060799/

相关文章:

azure-active-directory - 从元数据端点缓存颁发者和 key

c# - 使用应用程序客户端 key 访问 Azure Key Vault key

azure-active-directory - Power Automate 自定义连接器 - token 无效、受众无效

azure - Azure AD 应用程序 API 权限中未授予 API 权限状态警告

oauth - Microsoft Graph API 访问租户外用户的基本信息

reactjs - Azure Active Directory - 如何为我在租户下注册的应用程序提供 http redirectUri

azure - 如何为 PostgreSql 单服务器的 Azure 数据库创建服务主体

azure - 通过 Microsoft Graph API 注册应用程序无法在 Azure 中的企业应用程序下显示它们

更改为不同的 Azure 订阅时,Azure PowerShell 脚本不起作用

azure - 验证访问 token 的到期时间