0

我正在使用Visual Studio 2012並且正在玩弄Windows Phone 7.1應用程序開發。這是一個新創建的項目。爲什麼WebRequestMethods在當前上下文中不存在?

當我使用此代碼時,爲什麼會出現此錯誤?

The name 'WebRequestMethods' does not exist in the current context 

代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Microsoft.Phone.Controls; 

... 

public MainPage() { 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com"); 
    request.Method = WebRequestMethods.Http.Post; 
} 

... 

現在看來似乎無法識別WebRequestMethods是System.Net的一部分。如果我指定System.Net.WebRequestMethods.Http.Post,它也會失敗。

回答

相關問題