![](/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.