2011-10-02 36 views
0

我在Visual Studio 11在Windows 8嘗試這是我看到的,我不能用WebClient要做到這一點,所以我嘗試使用HttpClient如何從網站檢索內容與VS 11

var client = new HttpClient(); 
var response = client.Get("http://google.com"); 
var result = XDocument.Parse(response.Content.ReadAsString()); 

我的問題是,我總是得到結果爲null。作爲迴應,我得到一個狀態代碼200(確定),但我看不到內容。

我在做什麼錯?

謝謝。

+0

爲什麼你不能使用WebClient? – SLaks

+1

另外,Google.com不是有效的XML。 – SLaks

+0

@SLaks:我包括Syste,.Net,但它沒有找到WebClient,它不適用於任何網站,我想從頁面獲取xml – Kobe

回答