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.AppSetti ngs("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. 4 1266
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
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Ibrahim." wrote:
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.AppSetti ngs("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.
You need to pass the ContentLength header as well for the pdf to work.
Ibrahim. wrote:
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.AppSetti ngs("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.
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
"Peter Bromberg [C# MVP]" wrote:
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
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Ibrahim." wrote:
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.AppSetti ngs("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.
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
"Peter Bromberg [C# MVP]" wrote:
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
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Ibrahim." wrote:
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.AppSetti ngs("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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: GRE |
last post by:
I'm hoping someone can help with this problem; I've seen only a handful of
postings related to it, but with no clear resolution.
I have an ASP.NET 1.1 page that downloads requested files via the...
|
by: Craig Fox |
last post by:
Does anyone know of a fix for this. I have found several references to it
but this one describes it the best:
http://www.systemwebmail.com/faq/4.4.8.aspx
Unfortunately no solution is aparent...
|
by: Stu |
last post by:
Hi,
I have a 3 tier system using web services
I want to attach on the 3rd tier - data access
to the middle tier - business rules
and call the business rule tier from the front end to get the...
|
by: Ibrahim. |
last post by:
Hi,
When I open the download attachment link from my asp.net 2.0 application, I
get to see filedown download dialog box. When I select 'save' the file name
saves correctly.
The file name is...
|
by: djhexx |
last post by:
Hello. I have an ASP.NET application (C#) that I allow users to
upload files. Files get stored in a SQL2005 database. The file data
is stored in a varbinary(max) column.
When the user uploads...
| |
by: faiz03l |
last post by:
My program can catch the attachment of email but I don't know how to save the attachment(download attachment) ?
Can use the CommonDialog? or other?
I need solution...
Thank's
|
by: manirajmurali |
last post by:
hi all,
i have face this problem more 3 days.. if anybody help me..
i have upload file through php coding .. i have download that same file from server..
its coming empty file.. i dont know...
|
by: sbettadpur |
last post by:
hello,
Let me explain my requirement
1) I need to download attachment which are there in Microsoft Outlook email client.
2) Then i have to parse those files.
thanks
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |