Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 11th, 2003, 09:56 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default 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?
Old September 12th, 2003, 05:33 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping plain text into paragraphs igraham XSLT 4 July 16th, 2007 01:10 PM
getting plain text for .svc file bhavsac Windows Communication Foundation 8 November 9th, 2006 02:27 PM
Changing between bold and plain text in a text box funkybuddha Access 2 January 3rd, 2006 10:15 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.