【发布时间】:2015-12-12 02:33:42
【问题描述】:
我在 Azure 中有一个带有 AD 身份验证的 MVC Web 应用程序。当我在本地运行网站时,它使用 Azure AD 登录和注销都很好。但是我部署的 Azure 网站上的注销不起作用。用户保持身份验证状态,因此 SignOutCallback 操作始终重定向到 Home/Index。
这是我在创建项目时创建的开箱即用代码。
public class AccountController : Controller
{
/// <summary>
/// Use this method to sign into the website
/// </summary>
public void SignIn()
{
// Send an OpenID Connect sign-in request.
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
/// <summary>
/// Use this method to sign out of the website
/// </summary>
public void SignOut()
{
string callbackUrl = Url.Action("SignOutCallback", "Account", routeValues: null, protocol: Request.Url.Scheme);
Request.GetOwinContext().Authentication.SignOut(
new AuthenticationProperties { RedirectUri = callbackUrl },
OpenIdConnectAuthenticationDefaults.AuthenticationType,
CookieAuthenticationDefaults.AuthenticationType);
}
/// <summary>
/// Use this method to redirect to Home page, once the request has been authenticated
/// </summary>
/// <returns>An <see cref="ActionResult"/> object.</returns>
public ActionResult SignOutCallback()
{
if (Request.IsAuthenticated)
{
// Redirect to home page if the user is authenticated.
return RedirectToAction("Index", "Home");
}
return View();
}
}
我发现一个帖子 here 有类似的问题,并尝试了它的建议,但它对我不起作用。
还有其他人遇到过这个问题吗?
【问题讨论】:
标签: asp.net-mvc azure