啊。代码没看完,头开始痛了…………
像这样的权限代码太难维护了,建议参考一下基于角色的安全。它是基于URL的ASP.NET授权,相对来说比较简单,使用角色管理授权的话,一般将一种权限的功能独立到一个文件夹中,也就是浏览时的URL会相互区别开,然后在这个文件夹中添加一个web.config,配置一下授权的角色即可:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow roles="SYS01,C03,C04"/>
<deny users="*"/>
</authorization>
</system.web>
</configuration>
这个目录就阻止了除在角色SYS01,C03,C04之外的其他用户,然后页面里面不需要再判断任何权限了。
Please mark the post answered your question as the answer, and vote other helpful posts, so they will appear differently to other users for the same problem. 请将解决实际问题的帖子标记为“答案”,并给其他有帮助的帖子投票,这样其他人有同样问题的时候可以快速找到解决方案。谢谢!