How to redirect from OnActionExecuting in Base Controller?

前端 未结 4 983
刺人心
刺人心 2020-11-28 01:51

I have tried two ways: Response.Redirect() which does nothing, as well as calling a new method inside of the Base Controller that returns an ActionResult and have it return

4条回答
  •  借酒劲吻你
    2020-11-28 02:24

     public override void OnActionExecuting(ActionExecutingContext filterContext)
     {
        ...
        if (needToRedirect)
        {
           ...
           filterContext.Result = new RedirectResult(url);
           return;
        }
        ...
     }
    

提交回复
热议问题