Foxtable(狐表)用户栏目专家坐堂 → foxtable web server has started(error 404)


  共有5090人关注过本帖树形打印复制链接

主题:foxtable web server has started(error 404)

帅哥哟,离线,有人找我吗?
qwz405
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
foxtable web server has started(error 404)  发帖心情 Post By:2021/8/10 16:44:00 [显示全部帖子]

通过微信模板信息,点击【查看详情】登录,偶尔会弹错误页面:foxtable web server has started(error 404)
然后关闭错误页面,再点击【查看详情】又可以正常开启需要的页面。

个人感觉可能是登录验证的问题。

If e.host = "www.bbb.cn" Then Dim OpenID As String Dim sb As New StringBuilder sb.AppendLine("<meta name='viewport' c>") If e.GetValues.ContainsKey("code") Then Dim ul As String = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code" ul = CExp(ul,"wxd0106***","541e1c7d***",e.GetValues("code")) Dim hc As new HttpClient(ul) Dim jo As JObject = JObject.Parse(hc.GetData) If jo("openid") IsNot Nothing Then OpenID = jo("openid") e.AppendCookie("openid",OpenID) End If Else OpenId = e.Cookies("openid") End If Dim Verified As Boolean Dim dr As DataRow = DataTables("Users").SQLFind("[openid] ='" & OpenID & "'") If OpenId > "" AndAlso dr IsNot Nothing Then 'If OpenId > "" AndAlso dr IsNot Nothing AndAlso dr("离职") = 0 Then Verified = True ElseIf e.GetValues.ContainsKey("code") = False Then 'msgbox(UrlEncode(e.Request.URL.ToString)) Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd0106***&redirect_uri=" & UrlEncode(e.Request.URL.ToString) & "&response_type=code&scope=snsapi_base&state=123#wechat_redirect" 'Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd0106a4***&redirect_uri=http%3a%2f%2fwww.abc.cn&response_type=code&scope=snsapi_base&state=123#wechat_redirect" sb.Append("<meta http-equiv='Refresh' c>") e.WriteString(sb.ToString) Return '必须的 End If Dim wb As New weui If Verified = False Then wb.InsertHTML("<meta http-equiv='Refresh' c>") e.WriteString(wb.Build) '生成网页 Return '必须的 ElseIf e.path = "" Then '从登录页访问 wb.InsertHTML("<meta http-equiv='Refresh' c>") e.WriteString(wb.Build) '生成网页 Return '必须的 End If End If


 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/17 9:19:00 [显示全部帖子]

老师, 您好。

已经更新到最新版的Foxtable:修正了HttpRequest事件的Redirec方法失效的BUG。

但上述问题一直都存在:
每天第1次登录系统,报错:foxtable web server has started(error 404).
第2次点击相同的链接,可正常登录。

复制第1次报错的地址,如下所示:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd010***&redirect_uri=https%3a%2f%2fwww.abc.cn%2f20111117.htm%3fkey%3d%2b7FWJ00147&response_type=code&scope=snsapi_base&state=123#wechat_redirect

看上面记录,是要调整redirect,不知道要怎么调整?

 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/17 11:25:00 [显示全部帖子]

1、登录验证代码:
If e.host = "www.abc.cn" Then
    Dim OpenID As String
    Dim sb As New StringBuilder
    sb.AppendLine("<meta name='viewport' c>")
    If e.GetValues.ContainsKey("code") Then 
        Dim ul As String  = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code"
        ul = CExp(ul,"wxd01***","541e1c7d***",e.GetValues("code"))
        Dim hc As new HttpClient(ul)
        Dim jo As JObject = JObject.Parse(hc.GetData)
        If jo("openid") IsNot Nothing Then
            OpenID = jo("openid")
            e.AppendCookie("openid",OpenID)
        End If
    Else
        OpenId =  e.Cookies("openid")
    End If

    Dim Verified As Boolean
    Dim dr As DataRow = DataTables("Users").SQLFind("[openid]  ='" & OpenID & "' and [离职] = 0")
    If OpenId > "" AndAlso dr IsNot Nothing Then
        Verified  = True
    ElseIf e.GetValues.ContainsKey("code") = False Then 
        Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd01***&redirect_uri=" & UrlEncode(e.Request.URL.ToString) & "&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
        sb.Append("<meta http-equiv='Refresh' c>") 
        e.WriteString(sb.ToString)
        Return      '必须的
    End If

    Dim wb As New weui
    If Verified = False Then
        wb.InsertHTML("<meta http-equiv='Refresh' c>")        '直接跳转到登录页,显示无登录权限(需要输入密码).
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    ElseIf e.path = "" Then     '从登录页访问
        wb.InsertHTML("<meta http-equiv='Refresh' c>")     '直接跳转到首页
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    End If
End If


2、生成网页代码:
Select Case e.path     '开始生成网页
    Case "dd.htm"          '---营业系统 首页
        Functions.Execute("dd",e)
End select


3、每天首次登录链接:https://www.abc.cn/dd.htm?key=+202110A
报错:foxtable web server has started(error 404).
再点此链接,正常登录。


 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/17 13:14:00 [显示全部帖子]

1、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",".jpeg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar",".txt",".pdf",".xls",".xlsx",".doc",".docx"
            e.WriteFile(fl)
            Return   '这里必须返回
    End Select
End If


2、"dd"函数代码:
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.AddPageTitle("","litz","abc","ABC")    '标题

Dim openid As String = e.Cookies("openid")       '从cookie中获取用户openid
Dim dr1 As DataRow = DataTables("Users").SQLFind("[openid] = '" & openid & "' and [离职] = 0")  
Dim na As String = dr1("姓名")
Dim ks As String = dr1("课室")

If e.PostValues.Count = 0 Then     '如果是首次登陆,生成用户留言网页
    ***
Else
    ***
End If

e.WriteString(wb.Build)


 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/18 11:05:00 [显示全部帖子]

老师,您好。

使用上面的代码测试

1、使用:wb.AppendCookie("openid",OpenID), 代码如下:
If jo("openid") IsNot Nothing Then
    OpenID = jo("openid")
    wb.AppendCookie("openid",OpenID)
    msgbox(openid)
End If

每次登录,msgbox(openid) 能显示正常的openid值,但在"dd"页面,无法获取到这个openid,报错。
每次登录(不管登录多少次),"dd"页面都报错。


2、使用:e.AppendCookie("openid",OpenID), 代码如下:
If jo("openid") IsNot Nothing Then
    OpenID = jo("openid")
    e.AppendCookie("openid",OpenID)
    msgbox(openid)
End If

每次登录,msgbox(openid) 能显示正常的openid值,
第1次登录"dd"页面,无法获取到这个openid,报错。
第2次及后面的登录,正常。



我使用电脑版微信测试,通过退出再重新登录微信测试,以清空保存的Cookie数据。

 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/18 11:26:00 [显示全部帖子]

HttpRequest代码:
***
If e.host = "www.abc.cn" Then
    Dim OpenID As String
    Dim wb As New weui
    Dim sb As New StringBuilder
    sb.AppendLine("<meta name='viewport' c>")
    If e.GetValues.ContainsKey("code") Then 
        Dim ul As String  = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code"
        ul = CExp(ul,"wxd01***","541e1c7d***",e.GetValues("code"))
        Dim hc As new HttpClient(ul)
        Dim jo As JObject = JObject.Parse(hc.GetData)
        If jo("openid") IsNot Nothing Then
            OpenID = jo("openid")

            wb.AppendCookie("openid",OpenID)
            'e.AppendCookie("openid",OpenID)

            msgbox(openid)        
                  '不管使用e.AppendCookie还是wb.AppendCookie,都能弹出正确的openid,授权正常。
                  '使用wb.AppendCookie,每次登录,"dd"页面都无法获取到openid。
                  '使用e.AppendCookie,第1次登录"dd"页面,无法获取到这个openid,第2次及后面的登录能获取到openid

        End If
    Else
        OpenId =  e.Cookies("openid")
    End If

    Dim Verified As Boolean
    Dim dr As DataRow = DataTables("Users").SQLFind("[openid]  ='" & OpenID & "' and [离职] = 0")
    If OpenId > "" AndAlso dr IsNot Nothing Then
        Verified  = True
    ElseIf e.GetValues.ContainsKey("code") = False Then 
        Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd01***&redirect_uri=" & UrlEncode(e.Request.URL.ToString) & "&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
        sb.Append("<meta http-equiv='Refresh' c o n t e n t='0; url=" & ul & "'>")
        e.WriteString(sb.ToString)
        Return      '必须的
    End If


    If Verified = False Then
        wb.InsertHTML("<meta http-equiv='Refresh' c>")        '直接跳转到登录页,显示无登录权限(需要输入密码).
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    ElseIf e.path = "" Then     '从登录页访问
        wb.InsertHTML("<meta http-equiv='Refresh' c>")     '直接跳转到首页
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    End If
End If


Select Case e.path     '开始生成网页
    Case "dd.htm"  
        Functions.Execute("dd",e)
End select


2、"dd"内部函数代码:
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.AddPageTitle("","litz","abc","ABC")    '标题

Dim openid As String = e.Cookies("openid")       '从cookie中获取用户openid
msgbox(openid)     

***
e.WriteString(wb.Build)

 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/18 12:30:00 [显示全部帖子]


HttpRequest代码:
***
If e.host = "www.abc.cn" Then
    Dim OpenID As String
    Dim wb As New weui
    Dim sb As New StringBuilder
    sb.AppendLine("<meta name='viewport' c>")
    If e.GetValues.ContainsKey("code") Then 
        Dim ul As String  = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code"
        ul = CExp(ul,"wxd01***","541e1c7d***",e.GetValues("code"))
        Dim hc As new HttpClient(ul)
        Dim jo As JObject = JObject.Parse(hc.GetData)
        If jo("openid") IsNot Nothing Then
            OpenID = jo("openid")

            wb.AppendCookie("openid",OpenID)
            'e.AppendCookie("openid",OpenID)

            msgbox(openid)        
                  '不管使用e.AppendCookie还是wb.AppendCookie,都能获取(弹出)正确的openid。
                  '使用wb.AppendCookie,每次登录都会到这里,获取到的openid都不能传递到"dd"页面。
                  '使用e.AppendCookie,第1次登录无法传递openid到"dd"页面,第2次及后面的登录不会再到这里,因为可以使用第1次的openid,判定【 Verified  = True】,所以直达"dd"页面

        End If
    Else
        OpenId =  e.Cookies("openid")

            msgbox(OpenId)     'wb.AppendCookie无法获取到openid,e.AppendCookie第2次及后面的登录在这里能获取到openid >> Verified  = True
            msgbox(e.path)      '不管哪个登录,都是 dd.htm
    End If

    Dim Verified As Boolean
    Dim dr As DataRow = DataTables("Users").SQLFind("[openid]  ='" & OpenID & "' and [离职] = 0")
    If OpenId > "" AndAlso dr IsNot Nothing Then
        Verified  = True
    ElseIf e.GetValues.ContainsKey("code") = False Then 
        Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd01***&redirect_uri=" & UrlEncode(e.Request.URL.ToString) & "&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
        sb.Append("<meta http-equiv='Refresh' c o n t e n t='0; url=" & ul & "'>")     '返回到上面的授权,去获取openid
        e.WriteString(sb.ToString)
        Return      '必须的
    End If


    If Verified = False Then
        wb.InsertHTML(""& 报错页面 &"")        '错误就到这里
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    ElseIf e.path = "" Then     '从登录页访问
        wb.InsertHTML(""& 报错页面 &"")         '错误就到这里
        e.WriteString(wb.Build)     '生成网页
        Return  '必须的
    End If
End If


’不管是wb.AppendCookie还是e.AppendCookie,在这里openid都是存在的,认证都是通过的【Verified  = True】,就跳转到下面的"dd"页面。


Select Case e.path     '开始生成网页
    Case "dd.htm"  
        Functions.Execute("dd",e)
End select


2、"dd"内部函数代码:
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI

msgbox(e.Cookies("openid"))     

e.WriteString(wb.Build)


 回到顶部
帅哥哟,离线,有人找我吗?
qwz405
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:525 积分:5072 威望:0 精华:0 注册:2015/4/15 15:25:00
  发帖心情 Post By:2021/11/18 13:48:00 [显示全部帖子]

代码如下:
a1、a2为报错页面,放在授权代码之前,不需要权限(openid),任何人都可以登录。

    If Verified = False Then
        wb.InsertHTML("<meta http-equiv='Refresh' c o n tent='0; url=/a1.htm'>")
        e.WriteString(wb.Build)
        Return
    ElseIf e.path = "" Then     '从登录页访问
        wb.InsertHTML("<meta http-equiv='Refresh' c o n tent='0; url=/a2.htm'>")
        e.WriteString(wb.Build)
        Return
    End If

 回到顶部