2011-06-07 61 views
1

我有一個簡單的webclient連接到網頁並返回數據。代碼如下:簡單的webclient請求返回MS.InternalMemoryStream

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。任何想法的?

感謝, 彌敦道

回答

6

的ToString()返回類的名字 - 在這種情況下,InternalMemoryStream。你必須讀取流來獲得結果。檢查this

+0

謝謝!每天學些新東西!! – Nathan 2011-06-07 21:03:13