2012-07-26 84 views
0

Hy! 我正在向wp7發送一個請求。當php發送它的響應時,WP7應用程序收到的響應包含大量的空白字符和換行符。我的響應文本中的空白(請求wp7,響應php)

這裏是我的WP7響應回調:

void GetResponseCallback(IAsyncResult asynchronousResult) 
    { 
     try 
     { 
      HttpWebRequest request = asynchronousResult.AsyncState as HttpWebRequest; 
      HttpWebResponse response = request.EndGetResponse(asynchronousResult) as HttpWebResponse; 
      using (StreamReader sr = new StreamReader(response.GetResponseStream())) 
      { 
       string responseText = sr.ReadToEnd(); 
       Debug.WriteLine(responseText); 
       SaveResponseText(responseText);     
      } 
     } 
     catch (WebException e) 
     { 
     } 
    } 

這裏是我的PHP代碼的細節:

if ($_POST["event"] == "riaszt") 
    { 
if($count != 0) 
{   
    { 
     echo ok; 

    } 
} 
} 
+0

嘗試使用修剪()爲返回的數據 – asprin 2012-07-26 07:37:34

+0

user1520209:請閱讀您自己的問題一次。找到你犯了多少錯誤?不要急着寫所有的東西,如果我們趕緊回答它可能會使你的工作翻一番 – Makesh 2012-07-26 07:44:53

+0

你要麼寫回聲「OK」;要麼回聲$ OK;取決於你的情況。 – 2012-07-26 07:46:22

回答

0

如果幫助你,但,對於所有響應的servor我用我不知道此代碼=>

HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; 
    // End the operation 
    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); 
    Stream streamResponse = response.GetResponseStream(); 
    StreamReader streamRead = new StreamReader(streamResponse); 
    string responseString = streamRead.ReadToEnd(); 
    Debug.WriteLine("response ==> [" + responseString + "]"); 

但是,您的代碼是好的,你確定你的servor發送迴應?當你在瀏覽器中調用你的url時,你有迴應嗎? 也許是一個編碼問題...