Solved

changing content types

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

19 Experts available now in Live!

Get 1:1 Help Now