我正在使用sql成员资格提供程序处理web应用程序。 我已经在SQL中为用户映射了角色,并且用户正确地分配给了角色。 以下代码正常工作。基于位置的角色身份验证不起作用
protected void btnLogin_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtUserName.Text, txtPassWord.Text))
{
if (Roles.IsUserInRole(txtUserName.Text, "admin"))
Response.Redirect("~/Users/ViewUsers.aspx");
}
else
{
lblErrorMessage.Visible = true;
}
}
但我想做我的配置中的所有访问拒绝逻辑。 以下代码不起作用。不管角色如何,具有所有角色的用户都会被重定向。
<location path="Users">
<system.web>
<authorization>
<allow roles="admin"/>
<deny roles="user"/>
</authorization>
</system.web>
请让我知道我做错了吗?
它否认了所有角色。不起作用 – 2014-11-06 07:47:55