Controller中重写OnActionExecuting
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (user == null)
{
filterContext.HttpContext.Response.Redirect("/user/login");
}
base.OnActionExecuting(filterContext);
}
然后还有一个方法
public ActionResult orderlist(byte status = 0, int pageIndex = 1)
{
int rowCount = 0;
List<OrderModel> list = todo.....
return View(list);
}
问题:当user为null,而我要访问orderlist方法。按我的理解是先进OnActionExecuting,判断user为null,就转向到user/login方法,可是实际时先OnActionExecuting,然后进orderlist,再转到user/login 方法
为何?
沧海一幻觉