有关在 Windows 8 应用程序中使用休息服务发布方法的任何示例。请让我知道可能的链接。
问问题
2514 次
2 回答
6
尝试这个
using System.IO;
using System.Net.Http;
using System.Text;
var objHttpClient = new HttpClient();
var formParameters = "<details><id>1</id><name>test</name></details>");
var objHttpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://example.com/page");
objHttpRequestMessage.Content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes(formParameters)));
objHttpRequestMessage.Content.Headers.Add("Content-Type", "text/xml");
var result = await objHttpClient.SendAsync(objHttpRequestMessage);
于 2013-08-26T09:57:55.113 回答
2
使用System.Net.Http.StringContent类怎么样?
using System.Net.Http;
using System.Text;
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
var contentString = "<details><id>1</id><name>test</name></details>";
var httpClient = new HttpClient();
var httpRequestMessage = new HttpRequestMessage(
HttpMethod.Post,
"http://example.com/page");
httpRequestMessage.Content = new StringContent(
contentString,
Encoding.UTF8,
"text/xml");
var result = await httpClient.SendAsync(httpRequestMessage);
}
于 2013-08-26T17:51:04.453 回答