我正在使用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