Link to home
Start Free TrialLog in
Avatar of DJDoug
DJDougFlag for United States of America

asked on

content-disposition question for Windows XP, IE6

Hi, I am re-posting this question as I received no previous responses.  I initially made the question 100 points, but have now upped the question to 200 points.

I am using the following lines to allow my ASP page (which is a company report) to be downloaded
as an MS Word doc file.

<%
' ...
Response.ContentType = "application/vnd.ms-word"
Response.AddHeader "content-disposition","attachment; filename=" & strFileName
' ...
%>

When I run the page from home, I am using Windows XP Professional and IE6.  I get the dialog box which says "...open from location or save..."  When I select open from location and click OK, it brings me right back to the same dialog box, "...open from location or save...", and this loop continues indefinitely.

The download works fine on all of our company computers which run Windows 2000 and IE5.5 and lower.

However, some employees who need to access this page remotely from their home systems or laptops may be using Windows XP and IE6; thus, I need to get this fixed.

I've looked around for documentation on this, but found nothing.  Can someone please, at a minimum, point me to documentation (article or other) that discusses why this occurs and any possible fixes, or provide a fix for me.

Thanks
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Try changing the ContentType;

Response.ContentType = "application/msword"
Avatar of prokni
prokni

Have u tried to use inline instead of attachment?
Response.AddHeader "content-disposition","inline; filename=" & strFileName
Alos I agree with mqfranz, use application/msword
Avatar of DJDoug

ASKER

Prokni--I initially designed it as inline, but the boss wants it as an attachment because the report on the web page contains additional things that don't need to be in the report that employees save or print out.

mgfranz--I made the change and that solved the indefinite looping problem, but it still requires me to choose open from location twice before it actually opens the report in MS Word.  That is, I choose open file from location, it starts a download, then the open/save dialog box pops back up again--I choose open from location again and then it opens in MS Word.  Do I need to adjust the security settings in IE 6 perhaps?
ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DJDoug

ASKER

I normally download all MS patches/updates as soon as they are available, including the one released yesterday:

http://www.microsoft.com/windows/ie/downloads/critical/q321232/default.asp

The patch from Feb. 11, 2002 turns out to be my problem.  In discussing the security patch from Feb. 11, 2002, Microsoft states:

"After you install this patch, the Open button in the Open dialog box is unavailable if the Content-Type that is specified in the header does not match the file name that is specified in the Content-Disposition header. This behavior is by design for all cases, except if you try to open an .rtf file. To open an .rtf file, save the file, and then open it by using Windows Explorer."

mgfranz, I will award you the points, as I did not discover this until clicking through the links from the Microsoft link you gave me.  For 50 additional points...is there a way around this without using the stream method you suggested?  My strFileName above is something like "myfilename.doc" but the file is actually an ASP generated page, not a doc file sitting on our server.  Or, how would I use the stream method in that case?

Thanks
"My strFileName above is something like "myfilename.doc" but the file is actually an ASP generated page"

How are you creatinng the page, and is it being saved or stored in a "temp" folder?  What is the file extension?
Avatar of DJDoug

ASKER

The page being downloaded is "reportdownload.asp".  This page is called when user clicks on hyperlink (Click here to download an MS Word version of this report.) from "report.asp"

This is the beginning code on reportdownload.asp:

<%
intYear = Request("year")  ' Get year that the user selected to view.
intQuarter = Request("quarter") ' Get quarter that the user selected to view.
printDT = Now() ' Set report print date and time.
strFileName = "Qtr" & intQuarter & "HideMarket" & intYear & ".doc"
' The following two lines create the page as an MS Word attachment.
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition","attachment; filename=" & strFileName
%>

The remaining code is an exact replica of report.asp (which is the ASP page that generates the report in HTML to be viewed on the browser), with only some minor changes.

Sorry I wasn't too clear on that.