I have a MVC Web App in Azure with AD authentication. When I run the website locally, it signs in and out just fine, using Azure AD. But the signout on my deployed Azure website does not work. The user remains authenticated, so the SignOutCallback action always redirects to Home/Index.
This is out-of-the-box code that was created when I created the project.
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();
}
}
I found a post here with similar issues and have tried what it suggested but it did not work for me.
Has anyone else ran into this issue?