以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于内部函数与HTTPrequest的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=143777) |
-- 作者:狐来江湖 -- 发布时间:2019/12/4 10:51:00 -- 关于内部函数与HTTPrequest的问题 之前写在HTTPrequest中的页面代码,后来改为用内部函数,结果出现浏览器访问有的页面没有响应或者点击刷新之后才有响应,是什么问题? |
-- 作者:有点蓝 -- 发布时间:2019/12/4 11:08:00 -- HTTPrequest完整代码发上来看看 |
-- 作者:狐来江湖 -- 发布时间:2019/12/4 13:50:00 -- Dim fl As String = ProjectPath & "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",".jpeg", ".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar" e.WriteFile(fl) Return \'这里必须返回 End Select End If Dim servip As String = e.request.LocalEndPoint.ToString() Dim wb As New weui wb.AppendHTML("<style>.weui_grid_icon{width: 40px;height: 40px;}</style>") wb.AppendHTML("<style>.fox_grid_icon{width: 40px;height: 40px;vertical-align: middle;background-size: 40px 40px;}</style>") \'身份验证 If e.Path <> "zc.htm" Then 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" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码 If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then UserName = e.PostValues("username") Password = e.PostValues("password") End If End If Dim usr As DataRow = DataTables("ustbl").SQLFind("usnm = \'" & UserName & "\'") If usr IsNot Nothing AndAlso usr("uspw") = Password Then Verified = True End If If Verified AndAlso e.Path = "logon.htm" Then \'如果用户访问的是登录页,且身份验证成功 Dim userid As String = usr("usid") Dim usernc As String = usr("usnc") wb.AppendCookie("username",UserName) \'将用户名和密码写入cookie wb.AppendCookie("password",Password) wb.AppendCookie("userid",userid) wb.AppendCookie("usernc",usernc) wb.InsertHTML("<meta http-equiv=\'refresh\' c>")\'直接跳转到首页 e.WriteString(wb.Build) \'生成网页 Return \'必须的 ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then \'如果用户身份验证失败,且访问的不是登录页面 wb.InsertHTML("<meta http-equiv=\'refresh\' c>")\'直接跳转到登录页 e.WriteString(wb.Build) \'生成网页 Return \'必须的 End If End If \'开始生成网页 Select Case e.path Case "logon.htm" \'登录页面 Functions.Execute("usdenglu",e) Case "exit.htm" \'退出登录 Functions.Execute("eixt",e) Case "default.htm" \'首页 Functions.Execute("default",e) Case "zc.htm" Functions.Execute("zcym",e) Case "yh.htm" Functions.Execute("yonghu",e) Case "xgmm.htm" Functions.Execute("gaimm",e) Case "xxsc.htm" Functions.Execute("xxsc",e) Case "wdfbxx.htm" Functions.Execute("wdfbxx",e) Case "xxchakan.htm" Functions.Execute("xxchakan",e) Case "xqxx.htm" Functions.Execute("xqxx",e) End Select e.WriteString(wb.Build) \'生成网页 |
-- 作者:狐来江湖 -- 发布时间:2019/12/4 13:52:00 -- 老师帮忙看一下,感觉是换成内部函数后,浏览很不流畅,页面之间的切换变得卡顿了 |
-- 作者:有点蓝 -- 发布时间:2019/12/4 13:55:00 -- 去掉最后一行代码 e.WriteString(wb.Build) \'生成网页
|
-- 作者:狐来江湖 -- 发布时间:2019/12/4 14:06:00 -- 哦,这一句writestring看来不能多用啊。 谢谢老师
|
-- 作者:有点蓝 -- 发布时间:2019/12/4 14:14:00 -- 一次返回只能调用writestring一次 |
-- 作者:狐来江湖 -- 发布时间:2019/12/4 14:22:00 -- 嗯嗯,谢谢 我再检查一下内部函数与httprequest代码的衔接,看有没有重复的writestring语句
|