Click here to Skip to main content
15,123,509 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:

I am using response.OutputStream in page,
this page will return string value,
and i want put this string value in response.OutputStream

How to do that please

Updated 30-Oct-11 20:00pm

Response.OutputStream returns object of System.IO.Stream.

Have a look at below link.

You may convert object of System.IO.Stream to String as below.
using (StreamReader reader = new StreamReader(yourStream))
  string myString = reader.ReadToEnd();

Updated - Answer Updated based on your comment posted in Solution-1.
string s = "YourString";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);

Response.OutputStream.Write(bytes, 0, bytes.Length);
MrLonely_2 31-Oct-11 4:06am
Thanks man,
but i want to use Response.OutputStream as i want to use AJAX,
but it not worked for me,
Can you tell me how to enable AJAX in my project please.
I want clear way to do that
thank again
[no name] 31-Oct-11 5:08am
Welcome. :)
Have a look at my below Tip/Trick Article on "Asp.Net Ajax".
You can use OutputStream.Write method with buffer, offset and count as arguments.
HttpResponse.OutputStream property is of type System.IO.Stream

System.IO.Stream has built in ToString method to convert the current object into string content. So, you can write the code as:

MrLonely_2 31-Oct-11 1:01am
Thanks man,
but i want to pass the string to the OutputStream
[no name] 31-Oct-11 1:06am
My 5!. This is an easier way than what I proposed. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900