Solved

changing content types

Posted on 1998-12-10
3
182 Views
Last Modified: 2013-12-25
Instead of, or in addition to displaying a table of information about a database record returned on a web browser, I would like that table to be saved as a text file. How can I go about doing this? The book I have says you can change the content-type by saying:

   Response.Expires = 0
   Response.Buffer = TRUE
   Response.Clear
   Response.ContentType = "text/plain"

But that doesn't work. The idea is for the user to be prompted where to save a file which contains a record's data formatted as a table and based on the his/her query. I was hoping the prompt would appear by specifying a MIME type that the browser doesn't recognize. This is the only way I can think of to have the user prompted for a location to save a file. And the file is dynamic (generated on the fly) compared to a static type that resides on the server. Please help ASAP.
0
Comment
Question by:Pakdude
  • 2
3 Comments
 

Author Comment

by:Pakdude
ID: 1857104
Adjusted points to 240
0
 
LVL 1

Accepted Solution

by:
tjp earned 240 total points
ID: 1857105
This problem is discussed often on ASP mailing lists.  The best answer that's been thought of so far is to use the FileSystemObject's CreateTextFile() method to write the data to a file with a .WRI extension.  The browser will not try to display this file, unlike what happens when using a .TXT or .HTM extension.

You could display the data in their browser as usual, and also have a <META HTTP-EQUIV="refresh" CONTENT="1; URL="http://www.domain.com/site/file.wri"> to initiate a download of the information as well.  To make this all happen in one ASP, use Response.Buffer and also put the code to write out the text file before the META tag is sent to the client's browser.

0
 

Author Comment

by:Pakdude
ID: 1857106
Can you provide a bit of code to demonstrate? I'm getting confused with what to write in what files. I get Response object error 'ASP 0156 : 80004005'  Header Error because of the Expires = 0 part. That's what the Professional ASP book by Wrox says to use though. Microsoft doesn't have a solution for this. See Article ID: Q175324.


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

23 Experts available now in Live!

Get 1:1 Help Now