How to redirect from OnActionExecuting in Base Controller?

前端 未结 4 985
刺人心
刺人心 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:16

    It can be done this way as well:

    filterContext.Result = new RedirectToRouteResult(
        new RouteValueDictionary
        {
            {"controller", "Home"},
            {"action", "Index"}
        }
    );
    

提交回复
热议问题