wp8 入门到精通 WebClient Post
WebClient wc = new WebClient();
var URI = new Uri("http://your_uri_goes_here");
//If any encoding is needed.
wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
//Or any other encoding type.
//If any key needed
wc.Headers["KEY"] = "Your_Key_Goes_Here";
wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted);
wc.UploadStringAsync(URI, "POST", "Data_To_Be_sent");
void wc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
try
{
MessageBox.Show(e.Result);
//e.result fetches you the response against your POST request.
}
catch (Exception exc)
{
MessageBox.Show(exc.ToString());
}
}
===================================================
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
JObject ubody = new JObject();
ubody.Add(new JProperty("cmd", "user"));
JObject uData = new JObject();
uData.Add(new JProperty("name", ""));
uData.Add(new JProperty("sex", ""));
uData.Add(new JProperty("age", ""));
ubody.Add(new JProperty("data", uData));
string Content = JsonConvert.SerializeObject(ubody);
Uri address = new Uri("http://api.api.cn/");
WebClient webClient = new WebClient();
webClient.UploadStringAsync(address, "POST", Content);
webClient.Encoding = System.Text.Encoding.UTF8;
webClient.Headers[HttpRequestHeader.Accept] = "*/*";
webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
webClient.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)";
webClient.UploadStringCompleted += (s1, e1) =>
{
try
{
ShellToast toast = new ShellToast();
toast.Title = "Background Agent Sample";
toast.Content = e1.Result;
toast.Show();
}
catch (Exception ex)
{
}
};
wp8 入门到精通 WebClient Post的更多相关文章
- wp8 入门到精通 定时更新瓷贴
public class ScheduledAgent : ScheduledTaskAgent { static ScheduledAgent() { Deployment.Current.Disp ...
- wp8 入门到精通 虚拟标示符 设备ID
//获得设备虚拟标示符 wp8 public string GetWindowsLiveAnonymousID() { object anid = new object(); string anony ...
- wp8 入门到精通 仿美拍评论黑白列表思路
static bool isbool = false; private void BindGameDelete() { Tile tile = new Tile(); List<Color> ...
- wp8 入门到精通 生命周期
- wp8 入门到精通 ImageCompress 图片压缩
//实例化选择器 PhotoChooserTask photoChooserTask = new PhotoChooserTask(); BitmapImage bimg; int newPixelW ...
- wp8 入门到精通 Gallery
<Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.Resources> ...
- wp8 入门到精通 MultiMsgPrompt
List<NotifyMsg> arraymsg = new List<NotifyMsg>(); List<NotifyInfo> ArrayNotifyInfo ...
- wp8 入门到精通 数据库更新字段(一)
public class UserInfoDB : BaseDB { public UserInfoDB() : base(@"Data Source=isostore:\MakeLove\ ...
- wp8 入门到精通 启动系统分享照片任务
PhotoChooserTask photoChooserTask = new PhotoChooserTask(); photoChooserTask.Completed += photoChoos ...
随机推荐
- 教你看懂网上流传的60行JavaScript代码俄罗斯方块游戏
早就听说网上有人仅仅用60行JavaScript代码写出了一个俄罗斯方块游戏,最近看了看,今天在这篇文章里面我把我做的分析整理一下(主要是以注释的形式). 我用C写一个功能基本齐全的俄罗斯方块的话,大 ...
- 锋利的jQuery-4--animate()的用法
1.一般动画: $("btn").click(function(){ $("div").animate({"left" : "+= ...
- linux (centos) 单机50w+链接 内核参数配置
1 突破系统最大fd 查看当前文件描述符的限制数目的命令: ulimit -n .修改文件描述符的限制数目 2.1 临时改变当前会话: ulimit -n 2.2 永久变更需要下面两个步骤: ./ ...
- ExecutorService的十个使用技巧
ExecutorService] (https://docs.oracle.com/javase/8/docs/api/java/util/concurrent /ExecutorService.ht ...
- Swift翻译之-关于Swift
IMPORTANT 重要的 This is a preliminary document for an API or technology in development. Apple is suppl ...
- firefox访问失败的时间设置错误问题
在新装系统, 安装firefox后, 访问网页: baidu时 总是自动将http转换为https, 这个是baidu服务器的设置问题, 怪不到ff bd说,是ocsp证书错误, 然后将ocsp认证q ...
- this prototype 闭包 总结
this对象 整理下思路: 一般用到this中的情景: 1.构造方法中 function A(){ this.name="yinshen"; } var a=new A(); co ...
- cf.VK CUP 2015.B.Mean Requests
Mean Requests time limit per test 4 seconds memory limit per test 256 megabytes input standard input ...
- Unity中下载和本地保存实例
原地址:http://www.linuxidc.com/Linux/2011-10/45888.htm Download.cs using UnityEngine; using System.Coll ...
- [BZOJ2303][Apio2011]方格染色
[BZOJ2303][Apio2011]方格染色 试题描述 Sam和他的妹妹Sara有一个包含n × m个方格的 表格.她们想要将其的每个方格都染成红色或蓝色. 出于个人喜好,他们想要表格中每个2 × ...