首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在windows phone 8中将POST参数传递给后台传输请求

在windows phone 8中将POST参数传递给后台传输请求
EN

Stack Overflow用户
提问于 2014-11-17 13:39:28
回答 1查看 245关注 0票数 1

windows phone 8后台传输上传请求中如何传递post参数?我必须将参数传递给服务器(post参数名为"userfile“,参数名为"song.m4a”)

EN

回答 1

Stack Overflow用户

发布于 2014-11-17 17:38:44

代码语言:javascript
复制
// server to POST to
string url = "myserver.com/path/to/my/post";

// HTTP web request
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "text/plain; charset=utf-8";
httpWebRequest.Method = "POST";

// Write the request Asynchronously 
using (var stream = await Task.Factory.FromAsync<Stream>(httpWebRequest.BeginGetRequestStream,          
                                                         httpWebRequest.EndGetRequestStream, null))
{
   //create some json string
   string json = "{ \"my\" : \"json\" }";

   // convert json to byte array
   byte[] jsonAsBytes = Encoding.UTF8.GetBytes(json);

   // Write the bytes to the stream
   await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
}

尝试此代码并阅读此答案Http Post for Windows Phone 8

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26966239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档