如何在web.config中创建角色.. [英] how to create roles in web.config ..
问题描述
嗨...
i想知道我如何在网络配置中定义角色。
i有一个登录表(名称,密码,userrole)和userrole有三种类型(管理员,老师,学生)....我的网站根据我的角色有三个文件夹...
现在我在web.config中写了类似下面的东西...
< pre lang = HTML >
< location < span class =code-attribute> path = 管理员 >
& lt; system.web >
< 授权 >
< allow roles = 管理员 / >
< deny role = * / >
< / authorization >
< ; / system.web >
< / location >
< location 路径 = 教师 >
< system.web >
< 授权 >
< 允许 roles = 教师 < span class =code-keyword> / >
< deny roles = * / >
< / authorization >
< / system.web >
< / location >
< location 路径 = 学生 >
< system.web > ;
< 授权 >
< allow 角色 = 学生 / >
< < span class =code-leadattribute> deny roles = * / >
< / authorization >
< /system.web >
< / location >
和登录页面我的代码如下....
如果(Roles.IsUserInRole( Admin))
{
Response.Redirect( 〜/ Admin / Default.aspx);
}
if (Roles.IsUserInRole( 老师))
{
Response.Redirect( 〜/老师/ Default.aspx的跨度>);
}
if (Roles.IsUserInRole( 学生))
{
Response.Redirect( 〜/学生/ Default.aspx的跨度>);
}
但是我的代码没有执行上述任何条件...请帮助我告诉我如何在登录页面管理我的角色到web配置页面..
我可以在网络配置中创建角色然后请告诉我如何...
请帮助我.....
试试这个链接:
ASP.NET Forms Auth允许访问子目录中的特定文件,而其他所有文件都应被拒绝 [ ^ ]
hi...
i want to know how can i define roles in web config .
i have a logintable (name,password,userrole) and userrole is of three types (admin,teacher,student).... and my website have three folder according to my role ...
now i have written something like below in web.config...
<pre lang="HTML">
<location path="Admin">
<system.web>
<authorization>
<allow roles="Admin" />
<deny roles="*" />
</authorization>
</system.web>
</location>
<location path="Teacher">
<system.web>
<authorization>
<allow roles="Teacher" />
<deny roles="*" />
</authorization>
</system.web>
</location>
<location path="Student">
<system.web>
<authorization>
<allow roles="Student" />
<deny roles="*" />
</authorization>
</system.web>
</location>
and in login page i have code like below ....
if (Roles.IsUserInRole("Admin"))
{
Response.Redirect("~/Admin/Default.aspx");
}
if (Roles.IsUserInRole("Teacher"))
{
Response.Redirect("~/Teacher/Default.aspx");
}
if (Roles.IsUserInRole("Student"))
{
Response.Redirect("~/Student/Default.aspx");
}
but my code does not execute any of above condition...Please help me and tell me how can i manage my roles in login page to web config page ..
can i create role in web config then please tell me how ...
please help me .....
Try this link:
ASP.NET Forms Auth Allowing access to specific file in subdirectory when all others should be denied[^]
这篇关于如何在web.config中创建角色..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!