Solved

changing content types

Posted on 1998-12-10
3
185 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
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.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

832 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