title: Redirect to logon view and sign the user out on session timeout
body: <p>I'm trying to clear the session and sign the user out on session timeout and redirect to the login page. The login page is a partial view returned by the logon method in the account controller.
  When the session timeouts, the login view renders in the current page that the user was on before the session timeouts and the same thing with the URL. </p>
  
  <p>Web.Config</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.web&gt;
          &lt;authentication mode="Forms"&gt;
               &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
               &lt;sessionState timeout="45"&gt;&lt;/sessionState&gt;
          &lt;/authentication&gt;
      &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>BaseController.cs</p>
  
  <pre><code>protected override void OnActionExecuting( ActionExecutingContext filterContext )
  {
      HttpContext ctx = HttpContext.Current;
  
      if(ctx.Request.IsAuthenticated)
      {
          if (ctx.Session != null)
          {
              if (ctx.Session.IsNewSession)
              {
                  string sessionCookie = ctx.Request.Headers["Cookie"];
                  if (null != sessionCookie)
                  {
                     Session.Clear();
                     FormsAuthentication.SignOut();
                     var rr = new RedirectResult(loginUrl);
                     filterContext.Result = rr;
                  }
              }
          }
      }
  
      base.OnActionExecuting ( filterContext );
  }
  </code></pre>
  
  <p>I know that I need to do a redirect from the client, but I don't want to add another session timer. Is there anyway to do a "real" redirect from server when the session is timed out?</p>
  
  <p>What I want is when the session times out, the server should clear the current session, sign the user out and show the login view and not render the logon view on current page.</p>
  
  <p>Any tips?</p>