如何在Azure AD登录后重定向到特定页面? [英] How to redirect to particular page after Azure AD Login?
本文介绍了如何在Azure AD登录后重定向到特定页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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屋!
查看全文