title: ASP.NET IAuthorizationFilter OnAuthorization
body: <p>Hi I am trying to implement a custom Authorization filter</p>
  
  <pre><code> //The Authourization attribute on a controller
  public class CustomAdminAuthorizationFilter : IAuthorizationFilter
  {
      private readonly IAuthentication _authentication;
  
      public SageAdminAuthorizationFilter(IAuthentication authentication)
      {
          _authentication = authentication;
      }
  
      public void OnAuthorization(AuthorizationContext filterContext)
      {
         bool result = _authentication.Authorize(filterContext.HttpContext);
      }
  }
  </code></pre>
  
  <p>As you can see on the OnAuthorization I get back a result that is true of false.
  What do I need to set to return where I came from?</p>
  
  <p>EDIT:</p>
  
  <p>It still seems to throw me straight to the log in page</p>
  
  <p>I do inject IAuthetication </p>
  
  <pre><code> this.BindFilter&lt;CustomAdminAuthorizationFilter&gt;(FilterScope.Controller, 0);
     Bind&lt;IAuthentication&gt;().To&lt;CustomAuthenticationService&gt;();
  </code></pre>
  
  <p>Then I decorate my action in the controller as so.</p>
  
  <pre><code>[Authorize]
      public ActionResult Index()
      {
          ViewBag.Title = "Welcome";
          ViewBag.Message = "Welcome to ASP.NET MVC!";
  
          return View();
      }
  </code></pre>
  
  <p>In my web.config Im using</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>Should this be altered? </p>
  
  <p>Any help would be greatly appreciated.</p>