猿问

forms角色验证

http://www.mofile.com/pickup/mhoh53x6wh65s2r/

大家帮我看下问题出在哪了!

我想给admin文件设置一个权限,只有权限是admin的用户才可以访问

还有user文件夹,权限是user的用户才能访问!

我在用户登录时也分配了权限,但是一直转不过去!


HUWWW
浏览 464回答 2
2回答

慕容3067478

1、在Admin或user文件夹下的web.config中增加类似配置:<?xmlversion="1.0"encoding="utf-8"?><configuration> &nbsp; &nbsp;<system.web> &nbsp; &nbsp; &nbsp; &nbsp;<authorization> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<allow users="admin"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<deny users="*"/> &nbsp; &nbsp; &nbsp; &nbsp;</authorization> &nbsp; &nbsp;</system.web></configuration>2、在网站根目录下的web.config中统一配置:<configuration> &nbsp; &nbsp;<location path="admin"> &nbsp; &nbsp; &nbsp; &nbsp;<system.web> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<authorization> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--<allow roles="admin"/>--> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<allow users="admin"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<deny users="*"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</authorization> &nbsp; &nbsp; &nbsp; &nbsp;</system.web> &nbsp; &nbsp;</location> &nbsp; &nbsp;<location path="user"> &nbsp; &nbsp; &nbsp; &nbsp;<system.web> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<authorization> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--<allow roles="user"/>--> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<allow users="user"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<deny users="*"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</authorization> &nbsp; &nbsp; &nbsp; &nbsp;</system.web> &nbsp; &nbsp;</location></configuration>

凤凰求蛊

在admin文件夹下建立一个web.config。只允许admin访问,拒绝所有用户访问。<?xmlversion="1.0"encoding="utf-8"?><configuration><system.web><authorization><allow users="admin"/><deny users="*"/></authorization></system.web></configuration>
随时随地看视频慕课网APP
我要回答