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. Protocol Buffer技术详解(数据编码)

    Protocol Buffer技术详解(数据编码) 之前已经发了三篇有关Protocol Buffer的技术博客,其中第一篇介绍了Protocol Buffer的语言规范,而后两篇则分别基于C++和J ...

  2. IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol)。

    IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol).IMA ...

  3. linux kill信号列表

    linux kill信号列表 $ kill -l1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL5) SIGTRAP      6) ...

  4. 谈“技术含量”的问题

    最近又从离职同事那里听到这样的抱怨(原因),说做的事没有技术含量.想一想,从事车载软件开发这个行业快8年了,这个话题似乎从来没有停过.我自己曾经也为自己做的事是否有技术含量而苦恼过,今天就专门花点时间 ...

  5. jquery源码分析-工具函数

    jQuery的版本一路狂飙啊,现在都到了2.0.X版本了.有空的时候,看看jquery的源码,学习一下别人的编程思路还是不错的. 下面这里是一些jquery的工具函数代码,大家可以看看,实现思路还是很 ...

  6. ASP.NET 生成二维码(采用ThoughtWorks.QRCode和QrCode.Net两种方式)

    最近做项目遇到生成二维码的问题,发现网上用的最多的是ThoughtWorks.QRCode和QrCode.Net两种方式.访问官网看着例子写了两个Demo,使用过程中发现两个都挺好用的,Thought ...

  7. Milking Cows

    Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...

  8. [转]linux awk命令详解

    原文链接 : http://blog.chinaunix.net/uid-23302288-id-3785105.html   awk是行处理器: 相比较屏幕处理的优点,在处理庞大文件时不会出现内存溢 ...

  9. 北工大耿丹学院16级计科院3班C语言课程助教学期总结

    很荣幸得到邹老师,周老师,以及北工大耿丹学院各位老师的认可,担任计科院3班C语言课程助教,班主任为李光杰老师,很感谢李老师一学期的帮助,使得我更好的担任助教一职.我班学生31名,很愉快的与同学们度过一 ...

  10. CF#310 d2

    A:|c[1]-c[0]| B:A+-(oc)A[0]==0..n-1 C: #include <cstdio> int n,m,i,j,k,p; int ll,ca,cb,cc; int ...