ASPX to output text only (no headers)

O

Oleg Ogurok

Hi all,

I'm trying to create an ASPX page that will output itself as a text file.
For instance, if I have a file text.txt and I try to fetch it through
telnet, I get something like this

INPUT:
telnet localhost 80
GET /text.txt

OUTPUT: the contents of text.txt as is.

The problem is that I need to generate the text file on the fly via C#.
However, if I try it (in aspx.cs), the page is always prepended with headers
that look like the following:

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Mon, 15 Mar 2004 17:22:15 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=utf-8


Then the text follows.
Is there a way to make the page not output the headers?

Here's the code I'm using (doesn't work) in Page_Load():

Response.ContentType = "text/plain";

Response.Clear();

Response.ClearHeaders();

Response.Write("Text file starts here\r\nYep");

Response.End();

Thanks.
 
B

bruce barker

the http protocol requires at least 2 headers. each header is terminated by
a linefeed.

HTTP/1.1 200 OK // status
Content-Type: text/html; // content type

the headers are terminated by two lf's, followed by the content. IIS filters
look at these headers, to replace them yo proably need to write your own
isapi filter to strip them.


-- bruce (sqlwork.com)
 
J

Josh Carlisle

Just off the top of my head setting the response.contenttype would probably
be a good place to start.

Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top