Solved

content-disposition question for Windows XP, IE6

Posted on 2002-05-16
9
391 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:DJDoug
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 7014429
Try changing the ContentType;

Response.ContentType = "application/msword"
0
 
LVL 2

Expert Comment

by:prokni
ID: 7014468
Have u tried to use inline instead of attachment?
Response.AddHeader "content-disposition","inline; filename=" & strFileName
Alos I agree with mqfranz, use application/msword
0
 
LVL 4

Author Comment

by:DJDoug
ID: 7014536
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?
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 200 total points
ID: 7014592
Hmm... not sure... there is a patch available at MS that might have something to do with this;  http://support.microsoft.com/default.aspx?scid=kb;EN-US;q313675


Or you might look into using Stream;

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "application/msword"

Const adTypeBinary = 1
Dim strFilePath

strFilePath = "C:\files\file.doc" 'This is the path to the file on disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
%>
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Author Comment

by:DJDoug
ID: 7014705
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
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7014719
"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?
0
 
LVL 4

Author Comment

by:DJDoug
ID: 7014754
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.
0
 

Expert Comment

by:happygirl
ID: 7367937
0
 

Expert Comment

by:happygirl
ID: 7367941
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now