mvc中Actionfilter过滤权限直接弹出提示框

大家好,请问MVC 中flitercontext.result如何直接在浏览器用javascript弹出提示框。


using System.Web.Mvc;

public class PowerCheckAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext ctx)
    {
        if(权限验证不通过)
        {
            ctx.Result = new ContentResult() { Content = "<script>alert('权限不足!');history.back()</script>" };
        }
    }
}

需要验证权限的action加上PowerCheck属性

        [PowerCheck]
        public ActionResult logout()

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632