【发布时间】:2013-05-15 07:51:50
【问题描述】:
我是第一次处理身份验证和授权。
在我的 web.config 中,我有以下用于身份验证和授权的代码:
<authentication mode="Forms">
<forms loginUrl="Authentication.aspx" timeout="30" defaultUrl="Default.aspx" cookieless="AutoDetect" >
<credentials passwordFormat="Clear">
<user name="shiv" password="abc@123"/>
<user name="raj" password="abc@123"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
还有
<location path="Admin.aspx">
<system.web>
<authorization>
<allow users="shiv"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="users.aspx">
<system.web>
<authorization>
<allow users="shiv"/>
<allow users="raj"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
.cs 代码:
protected void btnLogin_Click(object sender, EventArgs e)
{
if(FormsAuthentication.Authenticate(txtUserName.Text,txtPassword.Text))
{
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text,true);
}
}
正如我的预期,当我从 'raj' 用户登录时,它应该将我重定向到 users.aspx ,但每次都将我重定向到 Default.aspx
为什么会这样?
我是不是做错了什么?
请帮帮我。
【问题讨论】:
标签: c# asp.net .net visual-studio-2010 authentication