简单的问题.如何在Controller中重写OnResultExecuting方法并强制使用不同的ActionResult?
示例代码如下.目前,原始的ActionResutl继续执行,我的新RedirectResult被忽略.
RedirectResult redirectResult = new RedirectResult("http://www.google.com"); filterContext.Result = redirectResult; base.OnResultExecuting(filterContext);
解决方法
如果您覆盖OnActionExecuted方法,则可以.
例:
protected override void OnActionExecuted(ActionExecutedContext filterContext) { filterContext.Result = new RedirectResult("http://google.com"); base.OnActionExecuted(filterContext); }