打开http://127.0.0.1/login.htm页面时,下述验证代码执行有问题,只执行msgbox(0)、1、2、8,3、4、5、6、7没有执行
现在将httprequest事件代码与login.htm内部函数代码贴出来
httprequest事件代码如下:
Dim fl As String = "e:\web\" & e.path
If filesys.FileExists(fl)
Dim idx As Integer = fl.LastIndexOf(".")
Dim ext As String = fl.SubString(idx)
Select Case ext
Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
e.WriteFile(fl)
Return '这里必须返回
End Select
End If
msgbox(0)
If e.Path = "index.htm" OrElse e.Path = "details.htm" OrElse e.Path = "getback.htm" OrElse e.Path = "register.htm" OrElse e.Path = "protocol.htm" OrElse e.Path = "zhucwc.htm" OrElse e.Path = "fillout.htm" OrElse e.Path = "quyu.htm" OrElse e.Path = "images.htm" OrElse e.Path = "success.htm" OrElse e.Path = "valid_register.htm" OrElse e.Path = "valid_fillout.htm" OrElse e.Path = "valid_quyu.htm" OrElse e.Path = "valid_images.htm" OrElse e.Path = "quyu_get.htm" Then
Select Case e.Path
Case "index.htm" '首页
Functions.Execute("index",e)
Case "details.htm" '详情页面
Functions.Execute("details",e)
Case "getback.htm" '找回密码页面
Functions.Execute("getback",e)
Case "register.htm" '注册第1页,手机注册
Functions.Execute("register",e)
Case "protocol.htm" '注册第2页,服务协议
Functions.Execute("protocol",e)
Case "zhucwc.htm" '注册第3页,注册完成,提示页面
Functions.Execute("zhucwc",e)
Case "fillout.htm" '注册第4页,完善资料
Functions.Execute("fillout",e)
Case "quyu.htm" '注册第5页,区域资料
Functions.Execute("quyu",e)
Case "images.htm" '注册第6页,上传照片
Functions.Execute("images",e)
Case "success.htm" '注册第7页,资料填写完成,提示页面
Functions.Execute("success",e)
Case "valid_register.htm" '验证页面(register)
Functions.Execute("valid_register",e)
Case "valid_fillout.htm" '验证页面(fillout)
Functions.Execute("valid_fillout",e)
Case "valid_quyu.htm" '验证页面(quyu)
Functions.Execute("valid_quyu",e)
Case "valid_images.htm" '验证页面(images)
Functions.Execute("valid_images",e)
Case "quyu_get.htm" '注册第3页,完善资料(填入所在/家乡省|市|区县)
Functions.Execute("quyu_get",e)
End Select
Else
Dim wb As New weui '1.加密解密 2.cookies释放
msgbox(1)
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("isj") '从cookie中获取用户名
Dim Password As String = e.Cookies("imm") '从cookie中获取用户密码
msgbox(2)
If e.Path = "login.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
msgbox(3)
If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm") Then
msgbox(4)
UserName = e.PostValues("isj")
Password = e.PostValues("imm")
End If
End If
If e.Cookies.ContainsKey("isj") AndAlso e.Cookies.ContainsKey("imm") Then
msgbox(5)
Dim dr As DataRow = DataTables("会员资料").Find("手机号 = '" & UserName & "'")
If dr IsNot Nothing AndAlso dr("密码") = Password Then
msgbox(6)
Verified = True
End If
End If
If Verified AndAlso e.Path = "login.htm" Then '如果用户访问的是登录页,且身份验证成功
msgbox(7)
wb.AppendCookie("isj",UserName) '将用户名和密码写入cookie
wb.AppendCookie("imm",Password)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
e.WriteString(wb.Build) '生成网页
Return '必须的
ElseIf Verified = False AndAlso e.Path <> "login.htm" Then '如果用户身份验证失败,且访问的不是登录页面
msgbox(8)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
Select Case e.Path
Case "login.htm" '登录页面
Functions.Execute("login",e)
Case "personal.htm" '个人中心
Functions.Execute("personal",e)
Case "myservice.htm" '我的服务
Functions.Execute("myservice",e)
End Select
End If
login.htm内部函数代码:
Dim e As RequestEventArgs = args(0)
Select Case e.Path
Case "login.htm"
Dim wb As New weui '登录页面
wb.AddForm("","form1","login.htm")
With wb.AddInputGroup("form1","ipg1","登录")
If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm") Then '判断是否是验证失败后的重新登录
wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮访问,则给用户一个2秒的提示.
End If
With .AddInputCell("ic1") '通过InputCell增加输入框(1表示突出显示,2表示红色警示图标)
.AddLabel("lsj","手机",0) '增加标签(0显示在左边)
.AddInput("isj","text",1).PlaceHolder= "请输入手机号" '增加输入框(0靠左显示,1居中显示,2靠右显示)
End With
With .AddInputCell("ic2")
.AddLabel("lmm","密码",0)
.AddInput("imm","password",1).PlaceHolder= "请输入密码"
End With
With .AddInputCell("ic3")
.AddLabel("lyz","验证码",0)
.AddInput("iyz","number",1).PlaceHolder= "请输入验证码"
.AddVcodeButton("vyz","获取验证码",2) '0靠左显示,1居中显示,2靠右显示
End With
.AddSwitch("jizhumima","记住密码")
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "登录", "","submit") '"/index.htm")
End With
With wb.AddButtonGroup("form1","btg2", False)
.Add("btn2", "免费注册","","/register.htm").Kind = 1
.Add("btn3", "忘记密码","","/getback.htm").Kind = 1
End With
End With
e.WriteString(wb.Build) '生成网页
End Select
[此贴子已经被作者于2017/3/19 11:17:03编辑过]