Reputation: 24322
I am using classic asp with vb script. The code for downloading the excel file is:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=ExportedData.xls"
Response.Write "<table><tr><td>1</td></tr></table>"
Then it works fine with the firefox, or any other down loader like orbit down loader. But I get error in IE 6.0/7.0/8.0.
The message is:
Internet Explorer cannot download myasppage.asp from secure.siteurl.com.
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
so what would be the problem?
FYI: I pass a query string parameter ysnDownload=1 to myasppage.asp page. & if it is passed then and then only it will have the ContentType as application other wise it will have default type (text/html).
Upvotes: 3
Views: 1414
Reputation: 2724
http://forums.asp.net/t/1224596.aspx
This line of code should work for you, just clear the headers also before exporting the file. Reponse.ClearHeaders();
Upvotes: 0
Reputation: 39413
Are you clear
ing and end
ing?
Response.Clear
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=ExportedData.xls"
Response.Write "<table><tr><td>1</td></tr></table>"
Response.End
Upvotes: 0
Reputation: 189457
I think the clue may be in the "secure.siteurl.com". My guess is you are sending this over https?
In which case you may be falling foul of a "bug" in the way IE handles downloads of this type. It downloads such documents to the cache then transfers or opens them from there. However when content is downloaded over https and does not specify caching or explicitly declare that the item should not be served from the cache the document is not saved in the cache. This can break the download save or open mechinism.
Try setting the Expires and CacheControl properties of the Response object to allow a very short window of caching. For example:-
Response.Expires = 1
Response.CacheControl = "private; max-age=10"
Upvotes: 2
Reputation: 2309
If you're on SSL (secure.siteurl.com uses SSL right?) then Internet Explorer is a bit picky with temporary files.
The headers I usually sent with it in this case are:
Cache-Control: public, must-revalidate
Pragma: hack
Upvotes: 0