P
pthawkes
Hello
I am having problems downloading a pdf file that I generate on the
fly. The file download will work in IE7 and Firefox, but not in IE6 as
per this post http://drupal.org/node/93787
I am trying to change my headers as the post suggests, with the code
below ...I run this in Firefox with the firebug add-on so that I can
capture the header information sent to the browser and only some of
the setting are changed and it seems to ignore the request that I am
making. Could anyone shed some light on this???
Basically I'm trying to set the Cache-Control to private and the
Pragma to cache
'##############################
'Start Code Snippet
'############################
Private Sub DoDownload(ByVal theFile As String)
'FileStream object read file from Local
Drive
Dim streamObj As FileStream =
File.OpenRead(Server.MapPath(theFile))
'Store File in Buffer
Dim buffer(CInt(streamObj.Length)) As Byte
'Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length)
'Close FileStream Object Set its Value to nothing
streamObj.Close()
streamObj = Nothing
Response.Expires = 0
Response.ContentType = "application/pdf"
Response.AppendHeader("Content-length",
buffer.Length.ToString())
Response.AppendHeader("Content-Disposition:",
"attachment; filename=Your_File.pdf")
Response.AppendHeader("Pragma", "Cache")
Response.AppendHeader("Cache-control", "private")
Response.OutputStream.Write(buffer, 0, buffer.Length)
Response.OutputStream.Flush()
Try
Response.End()
Catch ex As Exception
End Try
'##############################
'End Code Snippet
'############################
'##############################
' Start Response Headers
'############################
Date Wed, 08 Aug 2007 16:28:26 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
Content-Length 145563
content-disposition : attachment; filename=Your_File.pdf
Pragma Cache, no-cache
Set-Cookie COOKIETIMER=08/08/2007 17:28:14; path=/ COOKIETIMER=08/
blah...blah blah
Cache-Control no-cache
Expires -1
Content-Type application/pdf
##############################
' End Response Headers
'############################
I am having problems downloading a pdf file that I generate on the
fly. The file download will work in IE7 and Firefox, but not in IE6 as
per this post http://drupal.org/node/93787
I am trying to change my headers as the post suggests, with the code
below ...I run this in Firefox with the firebug add-on so that I can
capture the header information sent to the browser and only some of
the setting are changed and it seems to ignore the request that I am
making. Could anyone shed some light on this???
Basically I'm trying to set the Cache-Control to private and the
Pragma to cache
'##############################
'Start Code Snippet
'############################
Private Sub DoDownload(ByVal theFile As String)
'FileStream object read file from Local
Drive
Dim streamObj As FileStream =
File.OpenRead(Server.MapPath(theFile))
'Store File in Buffer
Dim buffer(CInt(streamObj.Length)) As Byte
'Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length)
'Close FileStream Object Set its Value to nothing
streamObj.Close()
streamObj = Nothing
Response.Expires = 0
Response.ContentType = "application/pdf"
Response.AppendHeader("Content-length",
buffer.Length.ToString())
Response.AppendHeader("Content-Disposition:",
"attachment; filename=Your_File.pdf")
Response.AppendHeader("Pragma", "Cache")
Response.AppendHeader("Cache-control", "private")
Response.OutputStream.Write(buffer, 0, buffer.Length)
Response.OutputStream.Flush()
Try
Response.End()
Catch ex As Exception
End Try
'##############################
'End Code Snippet
'############################
'##############################
' Start Response Headers
'############################
Date Wed, 08 Aug 2007 16:28:26 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
Content-Length 145563
content-disposition : attachment; filename=Your_File.pdf
Pragma Cache, no-cache
Set-Cookie COOKIETIMER=08/08/2007 17:28:14; path=/ COOKIETIMER=08/
blah...blah blah
Cache-Control no-cache
Expires -1
Content-Type application/pdf
##############################
' End Response Headers
'############################