Problems with Response.AddHeader

F

Frank Bishop

I am having problems downloading an Excel file after I export it with
another procedure. When I look at the file after export, it looks fine,
but when I use the sub below, it rearranges all the data in the excel
file to an unreadable glob. Help appreciated.
Thanks,
Frank

<code>
Sub DisplayDownloadDialog()
Dim ExportPath As String
ExportPath = Request.PhysicalApplicationPath + "Exported\"

Dim strPhysicalPath As String
Dim objFileInfo As System.IO.FileInfo

strPhysicalPath = ExportPath + Session.SessionID.ToString +
".xls"
objFileInfo = New System.IO.FileInfo(strPhysicalPath)

'Add Headers to enable dialog display
Response.AddHeader("Content-Disposition", "attachment;
filename=" & _
objFileInfo.Name)
Response.AddHeader("Content-Length",
objFileInfo.Length.ToString())
Response.ContentType = "application/octet-stream"
End Sub
</code>
 
T

tom.pesterDeLeTeTHISSS

I had some strange results when sending files to the browser to and they
where caused by data being sent to the browser before I send the file.

If I remember correctly I did Response.Clear or somthing similar just before
the code that sends the file to start with a clean sheet.

My next bet is that you give the browser the wrong info about the file size.

Cheers,
Tom Pester
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top