locked
User staying logged in even after Signing Out with MVC Forms Authentication on Windows Azure. RRS feed

  • Question

  • User1402180232 posted

    Hi,


    When I sign out of my application in Windows Azure website, the user is still signed in when I go back to the application i.e. user is not redirected to the login view.

    This issue only occurs in Windows Azure, not on my local machine or even if I deploy to my Arvixe hosting.

    Here is my SignOut code:

      public ActionResult SignOut()
            {
                FormsAuthentication.SignOut();
                
                HttpCookie cookie = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (cookie != null)
                {
                    cookie.Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies.Add(cookie);
                }
                
                // Invalidate the Cache on the Client Side
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.SetNoStore();
                Response.Cache.SetExpires(DateTime.Now.AddDays(-30));
                HttpContext.Session.Abandon();
    
                String ReturnUrl = Request.QueryString["returnUrl"];
                String RedirectTo = "";
                
                if (ReturnUrl == null || ReturnUrl.Length == 0)
                    ReturnUrl = AppSession.ReturnUrl;
    
                if (ReturnUrl != null && ReturnUrl.Length > 0)
                {
                    RedirectTo = ReturnUrl;
                }
                else if (AppSession.Parameters.RulesRedirectAfterLogout != null && AppSession.Parameters.RulesRedirectAfterLogout.Value.Length > 0)
                {
                    if (AppSession.Parameters.GeneralMaintenanceEnabled.Value != "true")
                        RedirectTo = AppSession.Parameters.RulesRedirectAfterLogout.Value;
                    else
                        return View("SignOut");
                }
                else
                {
                    return View("SignOut");
                }
    
                if (RedirectTo.IndexOf("signedout") < 0)
                    RedirectTo = RedirectTo + ((RedirectTo.IndexOf("?") >= 0 ? "&" : "?") + "signedout=1");
    
                return new RedirectResult(RedirectTo);
            }

    Here is my web.config authentication section:

     <authentication mode="Forms">
          <forms loginUrl="~/SignIn" timeout="20" domain="azurewebsites.net" name="fameCookie" path="/" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="true" defaultUrl="~/" />
        </authentication>

    I really hope you can help me with this as I am really keen to stay with Azure.

    Shane

    Tuesday, February 18, 2014 9:51 AM

Answers

  • User1402180232 posted

    I resolved this issue. It wasn't related to Windows Azure.

    User error....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 19, 2014 5:24 PM