Urgent!, download attachment corruption.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

When i download PDF document from asp.net page, it downloads but does not
open. Message shown is "file is damaged". The file opens when opened directly
from the folder.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Dim myFileInfo As New FileInfo(Session("dnload").ToString)
Dim myFilePath As String =
System.Configuration.ConfigurationManager.AppSettings("UploadFolder").ToString & "\" & myFileInfo.Name
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
Response.ContentType = "application/pdf"
HttpContext.Current.Response.AppendHeader("content-disposition",
"attachment;filename=" & myFileInfo.Name)
Response.WriteFile(myFilePath)
Response.Flush()
Response.End()

End Sub

What could be reason?


any thoughts are welcome.
 
Have you examined the actual PDF file to see what's in it? I have seen where
the markup from a Page (the aspx portion) gets included in a file download.
Try setting it up so your ASPX page has ONLY the Page directive and NO OTHER
MARKUP.
Best of luck,
Peter
 
You need to pass the ContentLength header as well for the pdf to work.
 
Hi Peter,

You are right, I examined the PDF contents & could see HTML embedded at end
of the file.

I tried removing everthing except page directive, but still the problem
exists?

Kindly give concrete solution;

thanks
 
Hi Peter,

You are correct, I examined the PDF file & could see HTML embedded at end of
the file.

I tried your suggestions but it does not work.

any concreate solutions?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top