返回MS.InternalMemoryStream的简单webclient请求

时间:2011-06-07 18:35:23

标签: c# silverlight windows-phone-7

我有一个简单的webclient连接到网页并返回数据。代码如下:

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);
    }
}

来自e.Result的数据是MS.InternalMemoryStream,而不是从网页返回的数据,从网页返回的数据应该是0或1.任何想法都是?

感谢, 森

1 个答案:

答案 0 :(得分:6)

.ToString()返回类的名称 - 在本例中为InternalMemoryStream。您必须阅读流才能获得结果。检查this