我正在创建一个actionfilter
来检查用户会话,但是当我运行网页时显示以下消息
This webpage has a redirect loop
这是代码
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);
}
}
控制器代码
public class AdminController : Controller
{
//
// GET: /Admin/
[CustomActionFilter]
public ActionResult Index()
{
return View();
}
}
一次又一次地调用此函数
注意:我是actionfilters