Foxtable(狐表)用户栏目专家坐堂 → [求助]


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

主题:[求助]

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


加好友 发短信
等级:小狐 帖子:391 积分:596 威望:0 精华:0 注册:2018/3/5 14:40:00
[求助]  发帖心情 Post By:2018/11/8 15:17:00 [只看该作者]

求助,怎么才能在登录前可以访问多个页面?

目前是除了登录页面,其他页面必须登录才能访问。

Dim fl As String = "d:\Web\" & e.path
Dim wb As New weui
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",".mp4",".mp3",".txt"
            e.WriteFile(fl)
            Return '这里必须返回
    End Select
End If
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") '从cookie中获取用户名
Dim Password As String = e.Cookies("password") '从cookie中获取用户密码
If e.Path = "UserLogin.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 dr As DataRow = DataTables("会员权限设置").sqlFind("用户账号='" & UserName & "'")
If dr IsNot Nothing Then
    If dr("用户密码") = Password Then
        Verified  = True
    Else
    End If
Else
End If
If Verified AndAlso e.Path = "UserLogin.htm"  Then '如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
    e.WriteString(wb.Build) '生成网页
    Return  '必须的
ElseIf Verified = False AndAlso e.Path <> "UserLogin.htm" Then '如果用户身份验证失败,且访问的不是登录页面
    wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
    e.WriteString(wb.Build) '生成网页
    Return  '必须的
End If
Select Case e.Path
    Case "AllCurricularTaxonomy.htm",""
        Functions.Execute("AllCurricularTaxonomy",e)  
    Case "CurricularTaxonomy.htm"
        Functions.Execute("CurricularTaxonomy",e)  
    Case "Allcourses.htm"
        Functions.Execute("Allcourses",e)  
    Case "AseriesOfCourses.htm"
        Functions.Execute("AseriesOfCourses",e)  
    Case "Courseware.htm"
        Functions.Execute("Courseware",e)  
    Case "OnlineVideo.htm"
        Functions.Execute("OnlineVideo",e)  
    Case "OnlineVideoA.htm"
        Functions.Execute("OnlineVideoA",e)  
    Case "Exercises.htm"
        Functions.Execute("Exercises",e)  
    Case "ExercisesA.htm"
        Functions.Execute("ExercisesA",e) 
    Case "UserLogin.htm"
        Functions.Execute("UserLogin",e)  
    Case "ExitLogin.htm"
        Functions.Execute("ExitLogin",e)  '退出登录页面
    Case "PersonalRegistration.htm"
        Functions.Execute("PersonalRegistration",e)  '个人注册页面
    Case "personalData.htm"
        Functions.Execute("personalData",e)  
    Case "PersonalCenter.htm"
        Functions.Execute("PersonalCenter",e)  '个人中心页面
  
End Select
e.WriteString(wb.Build)

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/8 15:19:00 [只看该作者]

参考红色代码

 

Dim fl As String = "d:\Web\" & e.path
Dim wb As New weui
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",".mp4",".mp3",".txt"
            e.WriteFile(fl)
            Return '这里必须返回
    End Select
End If
 
Select Case e.Path
    Case "AllCurricularTaxonomy.htm",""
        Functions.Execute("AllCurricularTaxonomy",e)  
e.WriteString(wb.Build)
return
    Case "CurricularTaxonomy.htm"
        Functions.Execute("CurricularTaxonomy",e)  
e.WriteString(wb.Build)
return

End Select

 
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") '从cookie中获取用户名
Dim Password As String = e.Cookies("password") '从cookie中获取用户密码
If e.Path = "UserLogin.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码

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


加好友 发短信
等级:小狐 帖子:391 积分:596 威望:0 精华:0 注册:2018/3/5 14:40:00
  发帖心情 Post By:2018/11/8 15:23:00 [只看该作者]

可以了,谢谢 甜老师

 回到顶部