![](/img/trans.png)
[英]ContactPicker is not working in Windows Phone 8.1 Silverlight
[英]HTTPClient post not working windows phone silverlight
我正在申請Silverlight應用程序。 現在我有執行POST的功能
public async Task<Webservice> addEvent()
{
var values = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("email", "qewfwef"),
new KeyValuePair<string, string>("password", "qewfwef"),
new KeyValuePair<string, string>("firstname", "qewfwef"),
new KeyValuePair<string, string>("lastname", "qewfwef"),
new KeyValuePair<string, string>("picture", "123456")
};
var httpClient = new HttpClient(new HttpClientHandler());
HttpResponseMessage response = await httpClient.PostAsync(url, new FormUrlEncodedContent(values));
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();
}
但是我在FormUrlEncodedContent
上FormUrlEncodedContent
gpt錯誤, FormUrlEncodedContent
可以幫忙嗎?
這是錯誤:
The type or namespace name 'FormUrlEncodedContent' could not be found (are you missing a using directive or an assembly reference?)
我遇到了同樣的問題,最終要做的是從NuGet的Microsoft.Net.Http軟件包中進行安裝。
在解決方案資源管理器中右鍵單擊項目名稱。
管理NuGet軟件包。
搜索“ microsoft.net.http”。
安裝。
string site = "https://www.yoursite.com";
var pairs = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("email", "qewfwef"),
new KeyValuePair<string, string>("password", "qewfwef"),
new KeyValuePair<string, string>("firstname", "qewfwef"),
new KeyValuePair<string, string>("lastname", "qewfwef"),
new KeyValuePair<string, string>("picture", "123456")
};
var client = new System.Net.Http.HttpClient();
var content = new FormUrlEncodedContent(pairs);
System.Net.Http.HttpResponseMessage response = await client.PostAsync(site, content);
if (response.IsSuccessStatusCode)
{
}
(在Windows Phone 8.1和10上測試)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.