Urgent!, download attachment corruption.

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.
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top