title: ASP.NET MVC: return Redirect and ViewData
body: <p>I have a login box in my MasterPage. Whenever the login information is not correct, I valorize <code>ViewData["loginError"]</code> to show the error message to the user.</p>
  
  <p>Login is an action of the UserController, so the form that contains the login has <code>action = "/User/Login"</code>.</p>
  
  <p>As a user can try to log in from any page, in case of success I redirect him to his personal page, but in case of error I want him to stay on the very same page where he tried to login. I've found that this works:</p>
  
  <pre><code>return Redirect(Request.UrlReferrer.ToString());
  </code></pre>
  
  <p>but it seems that, as I'm not returning a proper view, the data on ViewData is lost, so I cannot show the error message.</p>
  
  <p>Any suggestion on how to solve this and similar problems? </p>
  
  <p>Thanks</p>