惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
博客园 - 【当耐特】
D
Docker
Y
Y Combinator Blog
L
LangChain Blog
博客园 - 三生石上(FineUI控件)
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
B
Blog
The GitHub Blog
The GitHub Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
爱范儿
爱范儿
A
About on SuperTechFans
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 贤言叙语

WCF部署到IIS上调用报错:由于扩展配置问题而无法提供您请求的页面 Thinkpad 拆光驱更换光驱硬盘支架、拆光驱面板 T400 T440 无法打开登录所请求的数据库 "xxx"登录失败用户 'NT AUTHORITY\NETWORK SERVICE' - 贤言叙语 spread 程序调试时,未激活的提示解决 WCF服务客户端首页调用慢的问题处理 Inno Setup制作安装包的几个问题 Sqlite小数作差,会减不尽? 博文阅读密码验证 - 博客园 JS脚本修改控件宽度 WCF部署于IIS使用的几个问题总结 office2016与visio2016不能“并存”的问题分析 sqlite里执行查询提示未启用约束、主键冲突之——数据竟能超字段长度存储 VS2013添加解决方案内项目的引用,编译时提示找不到文件 plsql登录找不到可连接数据库 泛型、Linq 查询使用 格林时间10位串转本地时间 ORA-12154: TNS:could not resolve the connect identifier specified oracle远程连接太慢 DB设计原则(二)如何拆、分表
.Net 请求Web接口Post和Get方法
贤言叙语 · 2015-09-23 · via 博客园 - 贤言叙语

#region web服务请求 get post
static string DefaultUserAgent = "www.zhiweiworld.com";
public static String Get(string url)
{
System.Net.HttpWebRequest request = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest;
request.Method = "GET";
request.UserAgent = DefaultUserAgent;
System.Net.HttpWebResponse result = request.GetResponse() as System.Net.HttpWebResponse;
System.IO.StreamReader sr = new System.IO.StreamReader(result.GetResponseStream(), Encoding.UTF8);
string strResult = sr.ReadToEnd();
sr.Close();
//Console.WriteLine(strResult);
return strResult;
}

public static String Post(string url, System.Collections.Specialized.NameValueCollection para)
{
System.Net.WebClient WebClientObj = new System.Net.WebClient();

byte[] byRemoteInfo = WebClientObj.UploadValues(url, "POST", para);//请求地址,传参方式,参数集合

string rtContent = System.Text.Encoding.UTF8.GetString(byRemoteInfo);//获取返回值
return rtContent;
}
#endregion