To expand further on John's suggestion, here is some sample code I use to
retrieve an ID from a database, and stream a file which is in a directory
that isn't even accessible via the web...
------ BEGIN CODE ------
Dim fileType As String
Dim fileID As Integer
If Request.QueryString("type") Is Nothing _
Or Request.QueryString("id") Is Nothing Then
ShowNotFound()
End If
fileType = Request.QueryString("type").ToLower
fileID = Integer.Parse(Request.QueryString("id"))
Select Case fileType
Case "a"
'File requested is an attachment.
Dim fileData As DataSet
Dim inputFileName As String
Dim outputFileName As String
Dim fStream As FileStream
Dim reader As BinaryReader
ArticleManager.SetConnection(AppSettings("Database "))
fileData = ArticleManager.GetAttachmentInfo(fileID)
If fileData.Tables(0).Rows.Count = 0 Then ShowNotFound()
inputFileName = fileData.Tables(0).Rows(0)("AttachmentID")
inputFileName = "KBATT" & inputFileName & ".dat"
outputFileName = fileData.Tables(0).Rows(0)("AttachmentName")
If Not File.Exists(inputFileName) Then ShowNotFound()
fStream = New FileStream(inputFileName, FileMode.Open)
reader = New BinaryReader(fStream)
Response.ContentType = fileData.Tables(0).Rows(0)("AttachmentType")
Response.AddHeader("Content-Disposition", "attachment;filename=" &
outputFileName)
Response.AddHeader("Content-Length", fStream.Length)
Response.BinaryWrite(reader.ReadBytes(fStream.Leng th))
reader.Close()
Case Else
ShowNotFound()
End Select
Response.End()
End Sub
Private Sub ShowNotFound()
Dim referer As String
Response.Redirect("Error.aspx?code=404")
End Sub
--------END CODE --------
I was minding my own business when John Timney (Microsoft MVP) blurted out:
You can provide links that point instead to a page that streams the PDF to
the browser using an ID to pick the PDF, so there was no direct access.
At least that way you could restrict access using some criteria you were
happy with.
"Tiscali Nieuws" <*******************@hotmail.com**> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl... I have a pdf-file, but don't want someone to link to this file from
outsite my own website.
Is it possible to prevent this with ASP?
Thanks, Johan
--
Insert corny line here