在OnActionExecuting中阻止后面Action的执行

1 阻止后续Action的执行:

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var url = filterContext.HttpContext.Request.Path;
            if (url.Equals("/")) { url += string.Format("{0}/{1}", filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.ActionDescriptor.ActionName); }
            if (true)
            {
                Response.Write("");
            }

            //加了这句就不再走后面的Action
            filterContext.Result = new HttpNotFoundResult();
        }

2 弹出层无法弹出

转载于:https://www.cnblogs.com/Mylimo/p/3711874.html

你可能感兴趣的:(在OnActionExecuting中阻止后面Action的执行)