Beispiel #1
0
        /// <summary>
        /// 检测是否拥有某个菜单的浏览权限
        /// </summary>
        /// <param name="url"></param>
        private void CheckMenu(Uri uri)
        {
            Uri refUri = HttpContext.Current.Request.UrlReferrer;

            if (!HasMenu(uri) && refUri == null)
            {
                throw new Exception("No permission to view this page!");
            }
            else if (refUri != null && refUri.LocalPath != uri.LocalPath && Path.GetFileNameWithoutExtension(uri.LocalPath).ToLower() == "dialogview") //关键页面,进一步做权限验证
            {
                string objName = WebHelper.Query <string>("objName", "", false);                                                                       //去掉前置的_
                if (objName == "" || !WebHelper.IsKeyInHtml(objName.Trim('_', ' ')))
                {
                    string refObjName = WebHelper.Query <string>("objName", "", refUri.Query);
                    if (!string.IsNullOrEmpty(refObjName))
                    {
                        if (GridConfig.HasObjNameInRule(objName, refObjName))
                        {
                            return;
                        }
                    }
                    throw new Exception("No permission on this objName!");
                }
            }
        }