HttpWebRequest

  • Thread starter Thread starter user
  • Start date Start date
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 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
 
Back
Top