MVC actionfilter attribute redirect loop

825 views Asked by At

I am creating a actionfilter to check user session but when i run webpage shows the following message

This webpage has a redirect loop

here is the code

public class CustomActionFilter : ActionFilterAttribute, IActionFilter
    {
        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.Session["authenticate"] == null)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } });
            }
            base.OnActionExecuting(filterContext);
        }
    }

Controller code

public class AdminController : Controller
    {
        //
        // GET: /Admin/
       [CustomActionFilter]
        public ActionResult Index()
        {
            return View();
        }
}

this function is called again and again

note: i am newbie to actionfilters

0

There are 0 answers