string url=""; string param=""; string result = string.Empty; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); Encoding encoding = Encoding.UTF8; byte[] bs = Encoding.UTF8.GetBytes(param); string responseData = String.Empty; req.Method = "Post"; req.Accept = "application/json, text/javascript, */*; q=0.01"; req.ContentType = "application/json; charset=UTF-8"; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); reqStream.Close(); } using (HttpWebResponse response = (HttpWebResponse)req.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding)) { responseData = reader.ReadToEnd().ToString(); } result = responseData; }
POST请求——HttpWebRequest
原创zlulus ©著作权
文章标签 HttpWebRequest 编程开发 文章分类 .Net 后端开发
下一篇:多个不同类对象传输思路
-
java 监听post 请求
本文简要介绍了使用Servlet API监听POST请求的完整示例,并给广大读者详细介绍了Servlet的概念及使用方法。
Web java 服务器 Servlet post -
HttpWebRequest模拟POST提交防止中文乱码
测试通过,请求的为自己写的一般处理程序,代码如下:代码
asp.net 返回结果 javascript 公众号 -
C# HttpWebRequest发送post请求调用API
最近有用到C#客户端调用Java开发服务端的需求,将httphelper分享出来给需要的朋友
c# java json .net java开发