C# 将数据发布到windows应用商店应用程序中的服务器

C# 将数据发布到windows应用商店应用程序中的服务器,c#,.net,windows-8,httpclient,C#,.net,Windows 8,Httpclient,我希望以键、值对的形式向web服务发送数据。我不知道如何做到这一点,做后的基本方法是 HttpClient httpClient = new HttpClient(); HttpResponseMessage response = httpClient.PostAsync("http://50.16.234.220/helloapp/api/public/", new StringContent("asdad")).Result; 我的Api需要成对数据来获取数据,因此请告诉我如何在windo

我希望以键、值对的形式向web服务发送数据。我不知道如何做到这一点,做后的基本方法是

HttpClient httpClient = new HttpClient();
HttpResponseMessage response = httpClient.PostAsync("http://50.16.234.220/helloapp/api/public/", new StringContent("asdad")).Result;
我的Api需要成对数据来获取数据,因此请告诉我如何在windows 8应用程序中执行此操作。欢迎提供任何帮助。

试试这个

using System.Net.Http;

protected async override void OnNavigatedTo(NavigationEventArgs e)
{
    var data = new List<KeyValuePair<string, string>>
    {
        new KeyValuePair<string, string>("key_1", "value_1"),
        new KeyValuePair<string, string>("key_2", "value_1")
    };

    await PostKeyValueData(data);
}

private async Task PostKeyValueData(List<KeyValuePair<string, string>> values)
{
    var httpClient = new HttpClient();
    var response = await httpClient.PostAsync("http://50.16.234.220/helloapp/api/public/", new FormUrlEncodedContent(values));
    var responseString = await response.Content.ReadAsStringAsync();
}
使用System.Net.Http;
受保护的异步重写无效OnNavigatedTo(NavigationEventArgs e)
{
var数据=新列表
{
新的KeyValuePair(“key_1”、“value_1”),
新的KeyValuePair(“键2”、“值1”)
};
等待PostKeyValueData(数据);
}
专用异步任务PostKeyValueData(列表值)
{
var httpClient=新的httpClient();
var响应=等待httpClient.PostAsync(“http://50.16.234.220/helloapp/api/public/“,新格式URLEncodedContent(值));
var responseString=await response.Content.ReadAsStringAsync();
}

太好了。在问题中发布你的解决方案,让其他人知道。你能为这段代码的服务器端提供任何示例吗,特别是在W3S上的文件上传签出。