?
Solved

changing content types

Posted on 1998-12-10
3
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

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

Accepted Solution

by:
tjp earned 480 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

770 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