在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("<script language='javascript'>alert('您没有操作权限!');</script>");
            }

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

2 弹出层无法弹出

posted on 2014-05-06 16:43  limo  阅读(567)  评论(0编辑  收藏  举报