p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   text/plain forces download (http://p2p.wrox.com/showthread.php?t=3767)

pgtips September 11th, 2003 09:56 AM

text/plain forces download
I've got something weird going on with ASP/IE and I was wondering if anyone else has seen it. Basically, I'm trying to send plain text to the browser from an ASP page, but I just get a file download dialog when I run the page.

Here's a simple test page which exhibits this behaviour

<%@ Language=VBScript EnableSessionState=False %>
<% Response.ContentType = "text/plain"

When I browse to this page I just get a file download dialog. Its weird. I can browse to a text file and it displays just fine.

I tried telnet'ing to this page to see if any strange headers were being sent by ASP but I just got this standard looking stuff:

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Thu, 11 Sep 2003 14:41:52 GMT
Connection: Keep-Alive
Content-Length: 4
Content-Type: text/plain
Cache-control: private


Just had a thought while I was typing this and tried it with Netscape 6.2 and it displayed the text "abcd" in the browser just fine, so it must be some weirdness in IE6.

Anyone know anything about it?

pgtips September 12th, 2003 05:33 AM

For the sake of the archive, I've found a workaround for this; add this line:
Response.AddHeader "Content-Disposition", "inline;filename=temp.txt"

Yes, I know that adding a filename to the inline looks like nonsense, but I found an article in MSDN about how IE decides on the MIME type. This article talked about it looking at a combination of
- content-type header
- actual data sent
- file extension
(interestingly, it said that IE searches for a number of pre-defined content-types such as text/html, but text/plain isn't one of them!)

so, I decided that the .asp extension was probably confusing it and the only way I could think to associate it with a text file was to use the Content-Disposition header.

BTW it still works in NS6.2

Well, there you go, problem solved [?]

All times are GMT -4. The time now is 10:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.