asp.net mvc - logoff only works on layout after 1 refresh/request -


im working on log module application, need close session if same user login on different pc (close old session). part works when redirect filter logout view, logout view uses layout, , layout has menu inside if:

  @if (context.user.identity.isauthenticated)                 {                 <nav>                     <div>                          @html.action("_menu", "menu")                     </div>                 </nav>                } 

so expect logout view loaded without menu, when run application menu there, until refresh page happens, menu gone.

my logoff method:

        public actionresult logoff()     {         formsauthentication.signout();         httpcookie cookie = new httpcookie("sid")         {             expires = datetime.now.adddays(-10) // eliminar la cookie         };         httpcontext.response.cookies.set(cookie);           if (httpcontext.session["errormsg"] == null)//salida normal?         {             return redirecttoaction("logon", "account");         }         else//no                                  {             //session.abandon();             viewbag.error = httpcontext.session["errormsg"];             session.abandon();             return view();          }     } 


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -