Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 8 在windows phone 8中将POST参数传递到后台传输请求_Windows Phone 8_Upload_Background Transfer - Fatal编程技术网

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

Windows phone 8 在windows phone 8中将POST参数传递到后台传输请求,windows-phone-8,upload,background-transfer,Windows Phone 8,Upload,Background Transfer,如何在windows phone 8的后台传输上载请求中传递post参数?我必须将参数传递给服务器post参数名userfile,参数的文件名为song.m4a // server to POST to string url = "myserver.com/path/to/my/post"; // HTTP web request var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Conten

如何在windows phone 8的后台传输上载请求中传递post参数?我必须将参数传递给服务器post参数名userfile,参数的文件名为song.m4a

// 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);
}
试试这段代码,读一下答案