0
我試圖將表單身份驗證配置爲密碼保護文件夾。即使證書是正確的,當前也不會登錄任何用戶。表單身份驗證不能以正確的憑據登錄
這裏是我的代碼...
Web配置:
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="login.aspx" protection="All" timeout="999999">
<credentials passwordFormat="MD5">
<user name="admin" password="passwordhashhere" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
那麼最後的System.Web外:
<location path="Admin">
<system.web>
<authorization>
<allow users="admin" />
<deny users="*" />
</authorization>
</system.web>
</location>
然後在我的aspx:
<div class="user">
<p>Username:</p>
<br />
<asp:TextBox ID="TextBoxUser" runat="server"></asp:TextBox>
</div>
<div class="pass">
<p>Password:</p>
<br />
<asp:TextBox ID="TextBoxPass" runat="server" TextMode="Password"></asp:TextBox>
</div>
<div class="login">
<asp:Button ID="ButtonLogin" runat="server" Text="Log In" />
<asp:Label ID="LabelError" runat="server" Text=""></asp:Label>
</div>
然後在我的codebehin d:
Protected Sub ButtonLogin_Click(sender As Object, e As System.EventArgs) Handles ButtonLogin.Click
If Membership.ValidateUser(TextBoxUser.Text, TextBoxPass.Text) Then
If Request.QueryString("ReturnUrl") IsNot Nothing Then
FormsAuthentication.RedirectFromLoginPage(TextBoxUser.Text, False)
Else
FormsAuthentication.SetAuthCookie(TextBoxUser.Text, False)
End If
Else
LabelError.Text = "Invalid UserID and Password"
End If
End Sub