title: asp.net MVC confused by custom attributes creation
body: <p>hi i am trying to create a custom attribute for my MVC application so that i can call [CheckLogin] this is to check my cookie as i am not using forms authentification.</p>
  
  <p>i have created a class CheckLogin and this is in my App_Code folder and the code is as follows:</p>
  
  <pre><code>using System.Web.Mvc;
  using System.Attributes;
  using System.Diagnostics.CodeAnalysis;
  using System.Globalization;
  using System.Web;
  using System;
  
  namespace corian_MVC.Controllers
  {
      [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
      public class CheckLoginAttribute : FilterAttribute, IAuthorizationFilter
      {
          public CheckLoginAttribute() {}
  
          public void OnAuthorization(AuthorizationContext filterContext)
          {
              // TODO: perform your cookie checks
              if (!userIsAuthenticated)
              {
                  filterContext.Result = new RedirectResult(string.Format(
                            "/Admin/Login",
                            filterContext.HttpContext.Request.Url.AbsoluteUri));
              }
          }
      }
  }
  </code></pre>
  
  <p>what it does is not important here, the problem is i cant get my code to recognise this attribute if it is one in the first place, also how do i redirect to action if the login is failed ????</p>
  
  <p>many thanks</p>
  
  <p>my admin class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Mvc.Ajax;
  
  
  namespace corian_MVC.Controllers
  {
      [HandleError]
      public class AdminController : Controller
      {
          [AcceptVerbs(HttpVerbs.Get)]
          public ActionResult Index()
          {
              //check login is not banned
  
              if ((int)Session["LoginCount"] &gt;= 3) RedirectToAction("TooMany");
  
              return View();
          }
  
          public ActionResult Fraud()
          {
              Session["LoginCount"] = 3;
              return View();
          }
  
          public ActionResult TooMany()
          {
              return View();
          }
  
          [CheckLogin]
          public ActionResult Welcome()
          {
              return View();
          }
  
          private void Createcookie()
          {
  
          }
  
      }
  }
  </code></pre>