473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Outputing text file to response stream

Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and error,
here is the code:

Response.ContentType = "test/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv
Nov 19 '05 #1
8 2747
corrected:
Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and error,
here is the code:

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv

Nov 19 '05 #2
That doesn't mean I've sorted it lol, just correcting the post...
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
corrected:
Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and error,
here is the code:

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv


Nov 19 '05 #3
Quick guess - shouldn't this read

Response.ContentType = "text/plain";

and not

Response.ContentType = "test/plain";

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and error,
here is the code:

Response.ContentType = "test/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv

Nov 19 '05 #4
See my 2nd message.

Kev

"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Quick guess - shouldn't this read

Response.ContentType = "text/plain";

and not

Response.ContentType = "test/plain";

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and error,
here is the code:

Response.ContentType = "test/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv


Nov 19 '05 #5
try adding a filename header

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.AddHeader "Content-Disposition", "inline;filename=temp.txt"

or change your content type to text/html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
That doesn't mean I've sorted it lol, just correcting the post...
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
corrected:
Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and
error, here is the code:

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv



Nov 19 '05 #6
Excellent, I added the filename header and that worked. What is the
filename actually used for?

Thanks
Kev

"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
try adding a filename header

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.AddHeader "Content-Disposition", "inline;filename=temp.txt"

or change your content type to text/html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
That doesn't mean I've sorted it lol, just correcting the post...
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
corrected:

Hi all

I have the contents of a text file that I would like to output to the
response stream, however IE thinks it is XML and comes up with and
error, here is the code:

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);

Response.End();
Any ideas?
Thanks
KEv



Nov 19 '05 #7
Most browsers have no understanding of what text/plain actually is - so it
interprets the stream as something else. The filename simply tells it that
its a .txt file extension and the system should treat it accordingly.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
Excellent, I added the filename header and that worked. What is the
filename actually used for?

Thanks
Kev

"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
try adding a filename header

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.AddHeader "Content-Disposition", "inline;filename=temp.txt"

or change your content type to text/html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
That doesn't mean I've sorted it lol, just correcting the post...
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
corrected:

> Hi all
>
> I have the contents of a text file that I would like to output to the
> response stream, however IE thinks it is XML and comes up with and
> error, here is the code:
>
> Response.ContentType = "text/plain";
> Response.OutputStream.Write(buffer, 0, buffer.Length);
>
> Response.End();
>
>
> Any ideas?
> Thanks
> KEv
>



Nov 19 '05 #8
Thanks for your help John.

Kev

"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
Most browsers have no understanding of what text/plain actually is - so it
interprets the stream as something else. The filename simply tells it
that its a .txt file extension and the system should treat it accordingly.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
Excellent, I added the filename header and that worked. What is the
filename actually used for?

Thanks
Kev

"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
try adding a filename header

Response.ContentType = "text/plain";
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.AddHeader "Content-Disposition", "inline;filename=temp.txt"

or change your content type to text/html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
That doesn't mean I've sorted it lol, just correcting the post...
"Mantorok" <no**@tiscali.co.uk> wrote in message
news:de**********@newsfeed.th.ifl.net...
> corrected:
>
>> Hi all
>>
>> I have the contents of a text file that I would like to output to the
>> response stream, however IE thinks it is XML and comes up with and
>> error, here is the code:
>>
>> Response.ContentType = "text/plain";
>> Response.OutputStream.Write(buffer, 0, buffer.Length);
>>
>> Response.End();
>>
>>
>> Any ideas?
>> Thanks
>> KEv
>>
>
>



Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
2
by: Jeff G. | last post by:
Hello everyone, I have read through the newsgroups (thank God for 'em!) extensively looking for an example of how to pass a file (PDF) from a webresponse stream down to a web client. Here's the...
3
by: Peter | last post by:
Hello! Please, could you tell me, is it possible to create and stream for example a text file to the browser so that the file is not stored anywhere on a hard drive? User click's a link, eg....
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
3
by: premier | last post by:
I have a web page that's taking in data from text boxes, drawing a chart to represent the data, and then outputting the chart in PNG format. What I cant figure out how to do, is to output the...
0
by: Sid | last post by:
i am inplementing an intranet using asp 3.0 with vbscript. i want to know how to make my webserver download a file on the client.the file is grater than 60 mb. i have a script which does not...
5
by: Simon Rigby | last post by:
Hi folks, Apologies if this is not directly relevant but I was struggling to find a group with the appropriate context. So as my problem is in an aspx web site I thought I'd try here first....
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, The following code was suggested by one of the users in this newsgroup when a pdf file was requested by a user from an asp page. I used the similar code in my page and the very interesting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.