R
Rob Nicholson
We've implemented functionality to allow a user to download a document (any
document type) from the IIS server using the following code:
Response.Clear()
Response.ContentType = "application/x-msdownload"
Response.AddHeader("Content-Disposition", "attachment; filename=" &
System.IO.Path.GetFileName(FilePath))
Response.AddHeader("Content-Length", File.Length.ToString())
Response.WriteFile(FilePath)
Response.End()
When this response is sent back, IE prompts the user whether they want to
open, save or cancel the download. It works perfectly if they save the
document to their local hard drive and then open it. However, if they select
Open, the file downloads (quickly) but by the time Word opens, the copy in
temporary internet files has either disappeared or never saved in the first
place. Word displays an error about "The file could not be found".
I suspect it's something to do with caching but whilst I can find many posts
about stopping caching, I can't find any good examples in ASP.NET about
forcing the Word document to cache.
Any ideas?
Thanks, Rob.
document type) from the IIS server using the following code:
Response.Clear()
Response.ContentType = "application/x-msdownload"
Response.AddHeader("Content-Disposition", "attachment; filename=" &
System.IO.Path.GetFileName(FilePath))
Response.AddHeader("Content-Length", File.Length.ToString())
Response.WriteFile(FilePath)
Response.End()
When this response is sent back, IE prompts the user whether they want to
open, save or cancel the download. It works perfectly if they save the
document to their local hard drive and then open it. However, if they select
Open, the file downloads (quickly) but by the time Word opens, the copy in
temporary internet files has either disappeared or never saved in the first
place. Word displays an error about "The file could not be found".
I suspect it's something to do with caching but whilst I can find many posts
about stopping caching, I can't find any good examples in ASP.NET about
forcing the Word document to cache.
Any ideas?
Thanks, Rob.