【发布时间】:2013-05-27 10:36:41
【问题描述】:
我已经根据我从 MCTS 自定进度培训套件中了解的内容设置了以下表单身份验证,用于 MCTS 考试 70-562,但它没有进行身份验证...
<authentication mode="Forms">
<forms name="ortund" loginUrl="~/Login.aspx" timeout="30" slidingExpiration="true" />
</authentication>
</system.web>
<location path="Members">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
基本上,它需要允许未经身份验证的用户访问网站的所有区域,~/Members/ 以及其中的所有文件和文件夹除外。
目前它所做的只是不断地重定向回登录页面......我在这里缺少一个概念吗?我不明白我做错了什么。
这是登录代码:
Protected Sub lnkLogin_Click(sender As Object, e As System.EventArgs) Handles lnkLogin.Click
Dim db As New Database
' gets data from the database with the supplied credentials
' if true, the user exists, proceed to log in
If db.Login(txtEmail.Text, txtPassword.Text, "ortund") Then
FormsAuthentication.RedirectFromLoginPage(txtEmail.Text, True)
If Not String.IsNullOrEmpty(Request.Params("ReturnUrl")) Then
Response.Redirect(Request.Params("ReturnUrl"))
Else
Response.Redirect("~/Members/Default.aspx")
'Response.Redirect("~/AboutUs.aspx")
End If
Else
lblerr.Text = "Invalid username or password"
End If
End Sub
Members/Default.aspx 的 Page_Load:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If Context.User.Identity.IsAuthenticated Then
loadUserPage()
End If
End If
End Sub
【问题讨论】:
-
据我了解,这应该可行,允许 30 分钟的超时时间在用户执行操作时重置...
标签: asp.net vb.net web-config forms-authentication