……End If
Dim Verified As Boolean
Dim dr As DataRow = DataTables("WXUsers").Find("userid ='" & UserId & "'") '根据openid找出对应的行
If UserId > "" AndAlso dr IsNot Nothing AndAlso dr("permit") = True '授权成功
Verified = True
UserName = dr("name")
e.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=&&&&&&&&&&&redirect_uri=http%3a%2f%2f&&&&&&&&&&&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
sb.Append("<meta http-equiv='Refresh' content='0; url=" & ul & "'>") '跳转到授权链接
e.WriteString(sb.ToString)
return
End If
If Verified = False Then
e.WriteString("您无权访问") '生成网页
Return
Else If e.GetValues.ContainsKey("code") =True AndAlso Verified = True Then '如果通过授权链接跳转而来
sb.Append("<meta http-equiv='Refresh' c>")
e.WriteString(sb.ToString) '生成网页
Return
Else If e.GetValues.ContainsKey("code") =False AndAlso Verified = True Then '如果非通过授权链接跳转而来
'非第一次访问,且有UserID,直接通过
End If
'e.WriteString(sb.ToString) 这一句去掉
End If