Issues with "content-disposition" HTTP Header

I am working with ASP.NET 2.0 and ABCpdf .NET 6.1 (from WebSupergoo). I have a number of .aspx(.vb) pages that generate reports based on the QueryString and formats everything nicely for printing using HTML and CSS. I then have a ViewPDF.aspx(.vb) that opens in a new window and uses a QueryString to determine which report to generate and uses ABCpdf's "AddImageUrl" method to create a .pdf file. So far so good.

My issue comes at the end (Line 4 of the attached code from ViewPDF.aspx.vb). I have tested in IE 7 and Firefox 2 and get the same results.
- If I set the content-disposition Header to "attachment" it uses the dynamically assigned filename, but brings up the File Download dialog, which my client isn't happy with.
- Setting the content-disposition Header to "inline" opens the .pdf document directly in the window (a more desirable modus operandi) but when going to "Save" or "Email" always uses "ViewPDF.aspx.pdf" as the filename. This isn't desirable for the user!

Is there anyway of having the document download "inline" and at the same time have a dynamically assigned filename?
Response.Expires = -1000
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", pdfData.Length.ToString())
Response.AddHeader("content-disposition", "attachment; filename=" & sbFileName.ToString)
Response.BinaryWrite(pdfData)

Open in new window

DerekWatlingAsked:
Who is Participating?
 
SteveH_UKConnect With a Mentor Commented:
You may be able to solve this with an extended path, like:

http://hostname/page.aspx/Filename.pdf

That way the Save As link will generally get Filename.pdf even though page.aspx is running.
0
 
SteveH_UKCommented:
You will need to use a redirected post-back so that the browser gets the adjusted page location.
0
 
DerekWatlingAuthor Commented:
That works if I use something like
    http://hostname/ViewPDF.aspx/Filename.pdf?QueryString...
in the JavaScript that opens the new window.
0
 
SteveH_UKCommented:
Glad you got it to work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.