我正在我的应用程序中集成 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/