title: Redirect to another page when user is not authorized in asp.net mvc3
body: <p>I've read </p>
  
  <p><a href="https://stackoverflow.com/questions/6770563/how-to-easily-redirect-if-not-authenticated-in-mvc-3">How to easily redirect if not authenticated in MVC 3?</a> and 
  <a href="https://stackoverflow.com/questions/6329524/redirect-to-accessdenied-page-when-user-is-not-authorized">Redirect to AccessDenied page when user is not authorized</a> but the link from an answer (means <a href="http://wekeroad.com/2008/03/12/aspnet-mvc-securing-your-controller-actions/" rel="noreferrer">http://wekeroad.com/2008/03/12/aspnet-mvc-securing-your-controller-actions/</a>) doesn't work.</p>
  
  <p>I put</p>
  
  <pre><code>[Authorize(Users = "test")]
      public class RestrictedPageController: Controller
      {
  
          public ActionResult Index()
          {
             return View();
          }
  
   ....
      }
  </code></pre>
  
  <p>And in my web.config, I have already</p>
  
  <pre><code> &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
   &lt;/authentication&gt;
  </code></pre>
  
  <p>accordingly with <a href="https://stackoverflow.com/a/6770583/998696">https://stackoverflow.com/a/6770583/998696</a></p>
  
  <p>But when I want to access <code>/RestrictedPage/Index</code>, it must redirect me to other page (from other controller). Instead of this, the error appears like:</p>
  
  <pre><code>Server Error in '/Project' Application.
  
  The view 'LogOn' or its master was not found or no view engine supports the searched locations. The following locations were searched:
  ~/Views/Account/LogOn.aspx
  ~/Views/Account/LogOn.ascx
  ~/Views/Shared/LogOn.aspx
  ~/Views/Shared/LogOn.ascx
  ~/Views/Account/LogOn.cshtml
  ~/Views/Account/LogOn.vbhtml
  ~/Views/Shared/LogOn.cshtml
  ~/Views/Shared/LogOn.vbhtml
  </code></pre>
  
  <p>Before login, the <code>Logon</code> page form appears correctly but the above error appears when accessing <code>/RestrictedPage/Index</code> page. I can login with user different one authorized to access <code>RestrictedPage</code> page.</p>
  
  <p>Where is my mistake and how setup redirection ?</p>