Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   PDF Streaming in ASP.NET (https://www.warriorforum.com/programming/214601-pdf-streaming-asp-net.html)

osegoly 19th May 2010 01:04 PM

PDF Streaming in ASP.NET
 
Hi All,

On one of my websites (ASP.NET-based) I offer a bunch of PDFs for my users to download. There's also a private side, where I offer some private PDFs to members only.

On the private side, I use PDF streaming (Application/pdf approach) as I do not want my users to know where those PDF files are located on my server.

The issue I am having is with Safari users on Mac OS. For some reason it does not load the PDF files for these users. On all other browsers and platforms it works perfectly fine.

I've included my code below (stripped it down a bit for security reasons). Any help will be much appreciated.

Dim fname As String = ""
Dim folderName As String = Server.MapPath("/pdfs/private-pdfs/")

fname = Request.QueryString("cmd").ToString.Trim()

Dim extStr As Array
extStr = fname.Split(".")

Response.ContentType = "Application/pdf"

Dim FilePath As String = folderName & fname
Response.WriteFile(FilePath)
Response.End()

jaythedane 19th May 2010 02:23 PM

Re: PDF Streaming in ASP.NET
 
here is my code in c# -


string path = MapPath("\\Admin\\Uploads\\" + downloadID);
string name = getFileName(downloadID);

Response.AppendHeader("content-disposition","attachment; filename=" + name);

Response.ContentType = "application/octet-stream";
Response.WriteFile(path);
Response.End();

osegoly 19th May 2010 03:01 PM

Re: PDF Streaming in ASP.NET
 
Perfect. Thanks a lot :D

jaythedane 19th May 2010 03:56 PM

Re: PDF Streaming in ASP.NET
 
you're welcome


All times are GMT -6. The time now is 05:38 PM.