以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=127214)

--  作者:YOU
--  发布时间: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)

--  作者:有点甜
--  发布时间: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
--  发布时间:2018/11/8 15:23:00
--  
可以了,谢谢 甜老师