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的更多相关文章

  1. wp8 入门到精通 定时更新瓷贴

    public class ScheduledAgent : ScheduledTaskAgent { static ScheduledAgent() { Deployment.Current.Disp ...

  2. wp8 入门到精通 虚拟标示符 设备ID

    //获得设备虚拟标示符 wp8 public string GetWindowsLiveAnonymousID() { object anid = new object(); string anony ...

  3. wp8 入门到精通 仿美拍评论黑白列表思路

    static bool isbool = false; private void BindGameDelete() { Tile tile = new Tile(); List<Color> ...

  4. wp8 入门到精通 生命周期

  5. wp8 入门到精通 ImageCompress 图片压缩

    //实例化选择器 PhotoChooserTask photoChooserTask = new PhotoChooserTask(); BitmapImage bimg; int newPixelW ...

  6. wp8 入门到精通 Gallery

    <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.Resources> ...

  7. wp8 入门到精通 MultiMsgPrompt

    List<NotifyMsg> arraymsg = new List<NotifyMsg>(); List<NotifyInfo> ArrayNotifyInfo ...

  8. wp8 入门到精通 数据库更新字段(一)

    public class UserInfoDB : BaseDB { public UserInfoDB() : base(@"Data Source=isostore:\MakeLove\ ...

  9. wp8 入门到精通 启动系统分享照片任务

    PhotoChooserTask photoChooserTask = new PhotoChooserTask(); photoChooserTask.Completed += photoChoos ...

随机推荐

  1. The illustrated guide to a Ph.D.

  2. 【MVC5】ASP.NET MVC 项目笔记汇总

    ASP.NET MVC 5 + EntityFramework 6 + MySql 先写下列表,之后慢慢补上~ 对MySql数据库使用EntityFramework 使用域用户登录+记住我 画面多按钮 ...

  3. go tool proof

    echo list | go tool pprof -alloc_space gateway http://10.2.1.93:8421/debug/pprof/heap > abc.log e ...

  4. Windows 下配置使用MemCached(转载)

    工具: memcached-1.2.6-win32-bin.zip     MemCached服务端程序(for win) Memcached Manager             win下的Mem ...

  5. Component creation must be done on Event Dispatch Thread错误解决方法

    在用java swing 做例子,给页面设置皮肤样式的时候出现了这个错误: org.jvnet.substance.api.UiThreadingViolationException: Compone ...

  6. Usermod 命令详解 ------工作中修改shell时用 usermod -s /bin/csh home

     Usermod 命令详解 2012-09-11 11:01:36 标签:usermod 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.htt ...

  7. C++标准库异常类

    C++标准库异常类 2012-12-24 16:27 5269人阅读 评论(1) 收藏 举报  分类: c/c++(36)  C++标准库异常类继承层次中的根类为exception,其定义在excep ...

  8. du: fts_read 失败: 无法分配内存

    今天在查看一个大的文件时突然报出一个du: fts_read 失败: 无法分配内存的错误. 用 ulimit -a 查看下 core file size (blocks, -c) 0 data seg ...

  9. Linux的一个问题ircbot进程

    首先该问题目前还不清楚希望知道的人可以回复我mail fengtaotao2012x@163.com 今天执行一次常规服务器安全抽查的时候发现一台web服务器的一个奇怪的进程 而且更厉害的是cpu使用 ...

  10. 15个超实用的php正则表达式

    在这篇文章里,我已经编写了15个超有用的正则表达式,WEB开发人员都应该将它收藏到自己的工具包. 验证域名 检验一个字符串是否是个有效域名. $url = "http://komunitas ...