Memory Stream and Filenaming to PDF Browser?

I am trying to send a PDF to the browser from a memorystream and set the filename using the content-disposition of type inline.
The file will load into the browser via the Adobe plugin but when I click to save the PDF, the filename is not what I have specified in the header. Instead the filename is the .Net module + “.PDF” which sent the pdf through the response.  

For instrance mytest.aspx is called and sends back the PDF through the response and it loads in the Adobe plugin. I click to save the file but the filename is mytest.pdf instead of ReportFile.PDF.


            Dim fs As New MemoryStream
            fs = Current.Session("rptStream")
            Dim buffer(fs.Length) As Byte
            If fs.Length > 0 Then
                fs.Position = 0
                fs.Read(buffer, 0, fs.Length)

                Current.Response.Buffer = True
                Current.Response.ClearContent()
                Current.Response.ClearHeaders()
                Current.Response.ContentType = "application/pdf"
                Current.Response.AppendHeader("Content-Length", fs.Length.ToString())
                Current.Response.AppendHeader("Content-Disposition", "inline; Filename=\""" & “ReportFile.PDF” & "\""")
                Current.Response.OutputStream.Write(fs.GetBuffer(), 0, fs.Length)
                Current.Response.Flush()
                Current.Response.End()
                fs.Dispose()
                fs.Close()
            End If
centech-groupAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lucius_theCommented:
Try with:
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf")

Also before anything else, try adding this line before any other response lines:
Response.Clear()
robertG35Commented:
This is for prompting the user for a download:

Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf")

I am not prompting the user for a download I have the user load the PDF into the browser using INLINE not ATTACHMENT.

Current.Response.AppendHeader("Content-Disposition", "inline; Filename=\""" & “ReportFile.PDF” & "\""")

Also..  I had Response.Clear() at the beginning and it made no difference.  I believe that technically Response.ClearContents() is synonymous anyway.

lucius_theCommented:
I see. But, if you get a correct filename using the "attachment" method instead of "inline" method... maybe you can still use it ? The browser may be configured to automatically open the PDF in the external viewer. If it's not very important to get the viewer inside the browser frame, that is.
mohan_sekarCommented:
centech-group, it can not be done.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
centech-groupAuthor Commented:
No additional help needed
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.