如何在Azure AD登录后重定向到特定页面? [英] How to redirect to particular page after Azure AD Login?

查看:16
本文介绍了如何在Azure AD登录后重定向到特定页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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);
                        }
                    }
                });
        }

谢谢,

推荐答案

如何在成功登录后重定向到自定义页面

在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);
        }
    }

使用/ControlerName/actionName。在owin检查令牌并提取必要的详细信息后,用户将重定向到您指定的URL。

这篇关于如何在Azure AD登录后重定向到特定页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆