C# MVC权限拦截跳转到最外层的方法

项目运用MVC+easyui框架,对用户权限进行拦截的时候,用户登入权限已经过期的时候,需要跳转到登录页面。因为运用了easyui框架,所以有frame,导致不能跳转到最外层页面。

具体代码如下:

filterContext.Result = new RedirectResult("/Home/Index");

要使代码跳转到最外层方法,目前发现了两种方式:

 ContentResult Content = new ContentResult();
                    Content.Content = string.Format("<script type='text/javascript'>top.location.href='{0}';</script>", "/Home/Index");
                    //Content.Content = string.Format("<script type='text/javascript'>window.open('{0}','_top');</script>", "/Home/Index");//方式2
                    filterContext.Result = Content;

 

posted @ 2017-11-17 17:01  solatiry  阅读(950)  评论(0编辑  收藏  举报