ASPX to output text only (no headers)

  • Thread starter Thread starter Oleg Ogurok
  • Start date Start date
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.
 
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)
 
Just off the top of my head setting the response.contenttype would probably
be a good place to start.

Josh
 
Back
Top