HttpWebRequest

U

user

Hello
I have function:
HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create("http://myserver.org/index.php");
HttpWReq.KeepAlive = false;
HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
Stream receiveStream = HttpWResp.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
Char[] read = new Char[256];
int count=readStream.Read( read, 0, 256 );
while (count!=0)
{
richTextBox1.Text+=read;
count=readStream.Read( read, 0, 256 );
}
HttpWResp.Close();
readStream.Close();

But after that i have in richTextBox1 only: 'System.Char[]' string
(uninitialized read variable ?).
Why ?
How can i check if WebResponse exist (was received correctly?)

Thanx
 
I

INSTOK

I know nothing about .net, but:

1. how do you know the web contents are utf-8 encoded?
2. what you recieved in Char[] read is not 0 ended ---- not a safe string
 

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