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. 终端terminal配色

    切换到~/.bash_profile,无此.bash_profile文件可创建 在文件内粘入以下代码: #enables colorin the terminal bash shell export ...

  2. iOS 代理与block 逆向传值 学习

    一般在项目中出现逆向传值的时候就需要用到代理.block 或者通知中心了.由于公司的项目底层封装的很好,所以项目做了三四个月就算碰到需要逆传的情况也不用自己处理.但是最近遇到了一个特别的情况就需要自己 ...

  3. phpcms 采集教程

    Phpcms网站管理系统目前最新版本为Phpcms v9,作为国内主流CMS系统之一,目前已有数万网站的应用规模.那么其自带的采集模块功能如何呢,来看看吧. 文章采集 Phpcms v9默认内置有文章 ...

  4. Iterator<转>

    Iterator就是迭代器的意思. Iterator是一个接口,利用迭代器主要是获取元素,很少删除元素.有三个方法:    1)hasNext():判断是否有更多的元素,如果有返回true.    2 ...

  5. C# CryptoStream

    using System; using System.IO; using System.Security.Cryptography; namespace RijndaelManaged_Example ...

  6. C#多线程学习 之 线程池[ThreadPool](转)

    在多线程的程序中,经常会出现两种情况: 一种情况:   应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应                   这一般使用ThreadPo ...

  7. Base64封装类

    using System;using System.Collections.Generic;using System.Linq;using System.Web; /// <summary> ...

  8. sql分组取第一条数据

    sq分组取第一条数据的一个方法: select * from ( select row_number() over(partition by ID order by ID) as rownum , * ...

  9. Linux大神必备-文本编辑器

    导读 我们在 Linux 上不缺乏非常现代化的编辑软件,但是它们都是基于 GUI(图形界面)的编辑软件.正如你所了解的:Linux 真正的魅力在于命令行,当你正在用命令行工作时,你就需要一个可以在控制 ...

  10. Bellman-Ford算法

    #include<stdio.h> #define max 0xffffff ][]; //图的邻接矩阵 ]; int n;//顶点个数 int m;//边个数 struct Edge { ...