如何登录查看网站上的文件?

时间:2016-09-12 13:59:56

标签: html vb.net security web

我的网站有一系列文档存储在网络服务器(Windows 2012 R2)的文件夹中。

可以在只能由登录用户访问的页面上找到这些文档。这些文档是PDF文件,可以通过单击超链接下载。它们也可以在网络浏览器中查看。

目前,用户可以复制URL,将其提供给其他人,他们可以使用它来下载PDF,从而无需通过登录过程来查看登录页面后面的页面。

我们说网址为https://www.mywebsite.com/documents/adocument.pdf

如何保护这些文件,以便不仅可以发送网址而是提示登录?

以下是获取文档的代码。然后将这些推送到ASP.NET占位符。

Public Shared Function GetLoanDocLinks(ByVal iLoanID As Integer) As String
    Dim s As String

    s = ""
    Dim MyConn As FirebirdSql.Data.FirebirdClient.FbConnection
    Dim Adaptor As FirebirdSql.Data.FirebirdClient.FbDataAdapter
    Dim ds As DataSet
    Dim dr As DataRow
    Dim iNumRows, i As Integer
    Dim MySQL As String
    Dim myContext As HttpContext
    Dim MySession As HttpSessionState = System.Web.HttpContext.Current.Session

    myContext = HttpContext.Current

    ds = New DataSet

    'StrConn = ConfigurationManager.ConnectionStrings("FBConnectionString").ConnectionString
    MySQL = "SQL statement goes here"
    MyConn = New FirebirdSql.Data.FirebirdClient.FbConnection(DBNAME.ConnStr)
    Adaptor = New FirebirdSql.Data.FirebirdClient.FbDataAdapter(MySQL, MyConn)
    Adaptor.SelectCommand.Parameters.Add("@p1", FirebirdSql.Data.FirebirdClient.FbDbType.Integer).Value = iID
    Try
        Adaptor.Fill(ds)
    Catch ex As Exception
        GenExternals.LogEntry("Error:" & ex.Message)
    End Try

    iNumRows = ds.Tables(0).Rows.Count

    For i = 0 To iNumRows - 1
        dr = ds.Tables(0).Rows(i)
        s = s & "<a href='documents/" & Trim(dr("Filename")) & "' target='+new'>" & Trim(dr("description")) & "</a>&#32;&#32;"
        s = s & "<br /> "
    Next
    s = s & "<br />"
    MyConn.Close()
    Adaptor = Nothing
    MyConn = Nothing

    GetLoanDocLinks = s

0 个答案:

没有答案