我正在将 Azure AD 登录集成到我的应用程序中。我想在成功登录天蓝色广告后重定向到特定操作。我的 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);
}
}
});
}
Thanks,
登录成功后如何重定向到自定义页面
在 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 检查令牌并提取必要的详细信息后,用户将被重定向到您指定的 URL。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)