title: 'Login as another user' MVC 4 Windows Authentication
body: <p>I have an intranet project written in MVC 4 which uses Windows Authentication to authorise and authenticate users.</p>
  
  <p>I need to add a 'Login as another user' functionality.</p>
  
  <p>After some searching I found <a href="http://bytes.com/topic/asp-net/answers/874302-changing-user-when-using-windows-authentication" rel="noreferrer">this solution</a> which suggests returning a 401, and created the following Action (which is called using a form):</p>
  
  <pre><code>    // 
      // POST: /Home/LogOut
  
      [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult LogOut()
      {
          return new HttpUnauthorizedResult();
      }
  </code></pre>
  
  <p>The Action gets called, and the browser pops up a username and password window, however as the result redirects back to the Action, a 401 is always returned.</p>
  
  <p>How do I redirect the user back to the previous action, once they have logged in with the new credentials?</p>
  
  <p>Is there a way to invalidate the credentials on the server side instead of just returning a 401?</p>