tags:

views:

94

answers:

5

I have an ASP page which will create a record set from an SQL query and create an excel page using that by using Response.ContentType = "application/vnd.ms-excel" property being set.

When executing the file,it will show a save dialog for an excel file (whatever filename i have mentioned in Response.AddHeader) as

Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName

This works well in local .But when running from the server (i checked only in IE ),ITs showing me a dialog box to "OPen" "Save " the ASP file itself, IF i give Save , Its showing an error message like "Could not download ..."

Any idea how to solve this ?

A: 

try adding a MIME type on your IIS for your file type

Omu
That has no effect on dynamically generated content, it only affects the Content-Type header when static files are requested
AnthonyWJones
+1  A: 

Since it works fine on your local test machine then there probably isn't anything wrong with your code.

First step diagnostic is fire up fiddler on your client then attempt the download. Have a look in the fiddler trace and see what exactly is being sent by the server.

AnthonyWJones
+1  A: 

Make sure that the Active Server Pages web service extension is marked as Allow in the IIS settings on the server. (These are the terms from Windows 2003, in 2008 they might call it something else...)

svinto
+2  A: 

Even when you say it works ok local, there must be some problem in the code (or in the data).

Try removing the header and testing the page (in the server)

Eduardo Molteni
A: 

This is a long-shot but...

If your server is accessed over SSL and you are using IE6 the problem could be that "Internet Explorer file downloads over SSL do not work with the cache control headers"

If so adding the following header should fix it:

Response.AddHeader "pragma", "no-store, no-cache, must-revalidate"
pflunk