Hola, estoy haciendo una pagina para vender cursos por internet, el punto es que no e encontrado la forma de proteger los archivos .pdf que se supone los clientes deben descargar "despues" de haber pagado.
Loq ue eh hecho es lo sigueinte, mi hosting me da un panel de control en el que puedo proteger la carpeta, hize esto y por el momento eh solucionado el problema, ademas de ello, eh forzado la descarga mediante programacion con el siguiente codigo:
Try
Dim fullPath = Server.MapPath(archivoPath)
Dim name = archivoNombre
Dim ext = Path.GetExtension(name)
Dim type As String = ""
If Not IsDBNull(ext) Then
ext = ext.ToString.ToLower
End If
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Select Case ext
Case ".pdf"
type = "Application/pdf"
Case ".htm", ".html"
type = "text/HTML"
Case ".txt"
type = "text/plain"
Case ".doc", ".rtf"
type = "Application/msword"
Case ".csv", ".xls"
type = "Application/x-msexcel"
Case ".mp3", ".mpeg", ".mp2", ".wav", ".avi", ".dat", ".jpg", ".swf", ".jpeg", ".bmp"
type = "application/octet-stream"
Case ".exe"
type = "application/octet-stream"
Case Else
type = "text/plain"
End Select
Dim streamArchivo As IO.FileStream
streamArchivo = IO.File.Open(fullPath, IO.FileMode.Open)
Dim getContent(streamArchivo.Length) As Byte
streamArchivo.Read(getContent, 0, streamArchivo.Length)
streamArchivo.Close()
Response.AddHeader("content-disposition", "attachment; filename = " + name)
If type <> "" Then
Response.ContentType = type
End If
Response.BinaryWrite(getContent)
Response.End()
Catch ex As Exception
Dim Err = ex.Message
Return Err
End Try
Estuve leyendo en el msdn que hay formas de hacerlo mediante el config y tambein mediante programacion, les pido su ayuda si es que alguien lo hizo de esa manera.
Saludos
y graciasss