1

I have a simple webclient that connects to a webpage and returns the data. The code is as follows:

try
{
    WebClient webClient = new WebClient();
    Uri uri = new Uri("https://domain.com/register.php?username=" + txtbUser.Text);
    webClient.OpenReadCompleted +=
        new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
    webClient.OpenReadAsync(uri);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    if (e.Error == null)
    {
        //Process web service result here       
        MessageBox.Show(e.Result.ToString());
    }
    else
    {
        //Process web service failure here       
        MessageBox.Show(e.Error.Message);
    }
}

The data coming from e.Result is MS.InternalMemoryStream and not the data coming back from the webpage, the data coming back from the webpage should just be a 0 or 1. Any idea's?

thanks, Nathan

pickypg
  • 22,034
  • 5
  • 72
  • 84
Nathan
  • 2,461
  • 4
  • 37
  • 48

1 Answers1

6

.ToString() returns the name of the class - in this case, InternalMemoryStream. You have to READ the stream to get the result. Check this out

Community
  • 1
  • 1
n8wrl
  • 19,439
  • 4
  • 63
  • 103