这个怎么跟Dim sb As New StringBuilder
Dim Verified As Boolean
Dim UserName As String = e.Cookies("username") '从cookie中获取用户名
Dim Password As String = e.Cookies("password") '从cookie中获取用户密码
'如果在登录页面输入了用户名和密码后单击确定按钮
If e.Path = "logon.htm" AndAlso e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then
UserName = e.PostValues("username")
Password = e.PostValues("password")
End If
'验证用户身份
Dim dr As DataRow = DataTables("web端用户表").find("用户名='" & UserName & "'")
If dr IsNot Nothing AndAlso dr("密码") = Password Then
Verified = True
End If
If Verified AndAlso e.Path = "logon.htm" Then '如果用户访问的是登录页,且身份验证成功
e.Appendcookie("username",UserName) '将用户名和密码写入cookie
e.Appendcookie("password",Password)
e.WriteString("<meta http-equiv='Refresh' c>") '直接跳转到首页
Return '必须的
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then '如果用户身份验证失败,且访问的不是登录页面
e.WriteString("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
Return '必须的
End If
Select Case e.path
Case "logon.htm"
Dim wb As New WeUI
Dim s As String = FileSys.ReadAllText("D:\web\log.txt")
wb.InsertHTML(s)
sb.AppendLine("<form action='logon.htm' enctype='multipart/form-data' method='post' id='form1' name='form1'>")
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then '判断是否是验证失败后的重新登录
sb.AppendLine("用户名或密码错误!</br></br>")
sb.AppendLine("户名: <input name='username' id='username' value='" & UserName & "''><br/><br/>")
sb.AppendLine("密码: <input type='password' name='password' id='password' value ='" & Password & "'><br/><br/>")
Else
sb.AppendLine("户名: <input name='username' id='username'><br/><br/>")
sb.AppendLine("密码: <input type='password' name='password' id='password'><br/><br/>")
End If
sb.AppendLine("<input type='submit' name='sumbit' id='sumbit' value='登录'>")
sb.AppendLine("<input type='reset' name='reset' id='reset' value='重置'>")
sb.AppendLine("</form>")
e.WriteString(sb.ToString)
Case "exit.htm"
e.Appendcookie("username", "") '清除cookie中原来的用户名和密码
e.Appendcookie("password", "")
e.WriteString("<meta http-equiv='refresh' c>") '跳转到登录页
Case "", "default.htm"
sb.AppendLine("这是首页<br/><br/>")
sb.AppendLine("<a href='order.htm'>订购产品<a><br/>")
sb.AppendLine("<a href='product.htm'>产品列表<a><br/>")
sb.AppendLine("<a href='exit.htm'>退出登录<a><br/>")
e.WriteString(sb.Tostring)
Case "order.htm"
e.WriteString("这是订购页")
这个结合在一起呢老师登录的