WPF和Windows Phone Post组装函数
2015-08-05 22:33
309 查看
private async void PostFun(Uri uri,string postdata)
{
//实现Post数据的访问
//postdata格式:phone=18712345678&password=12345678
try
{
Dictionary<String, String> dic = UnpackData(postdata);
FormUrlEncodedContent content = new FormUrlEncodedContent(dic);
HttpResponseMessage response = await Helper.httpclient.PostAsync(uri, content);
Helper.HttpFeed = await response.Content.ReadAsStringAsync();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private Dictionary<String, String> UnpackData(string postdata)
{
//postdata格式:phone=18712345678&password=12345678
//自动完成格式转换功能
Dictionary<String, String> dic = new Dictionary<string, string>();
string []data=postdata.Split('&');
for (int i = 0; i < data.Length;i++ )
{
string[] datadetails = data[i].Split('=');
dic.Add(datadetails[0], datadetails[1]);
}
return dic;
}
private async void PostFun(Uri uri,string postdata)
{
//实现Post数据的访问
//postdata格式:phone=18712345678&password=12345678
try
{
Dictionary<String, String> dic = UnpackData(postdata);
FormUrlEncodedContent content = new FormUrlEncodedContent(dic);
HttpResponseMessage response = await Helper.httpclient.PostAsync(uri, content);
Helper.HttpFeed = await response.Content.ReadAsStringAsync();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private Dictionary<String, String> UnpackData(string postdata)
{
//postdata格式:phone=18712345678&password=12345678
//自动完成格式转换功能
Dictionary<String, String> dic = new Dictionary<string, string>();
string []data=postdata.Split('&');
for (int i = 0; i < data.Length;i++ )
{
string[] datadetails = data[i].Split('=');
dic.Add(datadetails[0], datadetails[1]);
}
return dic;
}
相关文章推荐
- rewrite(摘自Yii2)
- swift学习1 oc swift混编
- 增加eclipse的内存
- ubuntu服务管理
- [转载] iOS开发 - 封装文件上传工具类
- SPOJ--K-query (线段树离线) 离线操作解决一些问题
- leetcode Balanced Binary Tree 题解
- NYOJ 33 蛇形填数
- Java笔试面试题001
- Cordova android框架详解
- 深入集合框架之HashSet源码剖析
- YUV格式学习:YUV420P、YV12、NV12、NV21格式转换成RGB24
- MS Project 使用之创建项目信息
- 企业应用开发面临的问题以及思考
- HDU 3912 Turn Right + HDU 1254 推箱子 + HDU 1983 Kaitou Kid - The Phantom Thief (2)
- PHP服务器框架(欢迎补充)
- 命令模式
- Tomcat server.xml UTF-8配置
- 新入行程序员应知的十个秘密
- Linux-命令-crontab