Dim Verified As Boolean
Dim dr2 As DataRow = DataTables("Users").Find("userid ='" & UserId & "'") '根据openid找出对应的行
If UserId > "" AndAlso dr2 IsNot Nothing AndAlso dr2("permit") = True '授权成功
msgbox(1)
Verified = True
UserName = dr2("name")
e.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
msgbox(2)
Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state={2}#wechat_redirect"
Dim ul2 As String = UrlEncode("http://" & DN)
ul = CExp(ul,CorpID,ul2,"123")
msgbox(ul)
sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
msgbox(sb.ToString)
e.WriteString(sb.ToString)
Return
End If