C# POST请求demo,contentType 格式:application/x-www-form-urlencoded
来源:互联网 发布:离散数据相关性 编辑:程序博客网 时间:2024/06/06 06:39
/* * url:为请求地址 * postData:请求内容例如:"key1=value1&key2=value2&key3=value3" */ public static string PostUrl(string url, string postData) { string result = ""; try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.Timeout = 800;//请求超时时间 byte[] data = Encoding.UTF8.GetBytes(postData); req.ContentLength = data.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(data, 0, data.Length); reqStream.Close(); } HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Stream stream = resp.GetResponseStream(); //获取响应内容 using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { result = reader.ReadToEnd(); } }catch(Exception e){} return result; }
阅读全文
0 0
- C# POST请求demo,contentType 格式:application/x-www-form-urlencoded
- Post请求传递参数时,最好在请求头加上item.ContentType = "application/x-www-form-urlencoded";
- post 请求 application/x-www-form-urlencoded。android 中文 乱码
- contentType的详细解释 application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
- http post xml 表单提交(application/x-www-form-urlencoded)
- http请求中application/x-www-form-urlencoded的含义
- contenttype 为application/x-www-form-urlencoded 和 application/json 区别和说明
- nginx静态资源文件无法访问,403 forbidden错误
- android TextInputLayout使用
- ansible学习小记
- dp专题:最长公共子序列
- 鸡兔同笼
- C# POST请求demo,contentType 格式:application/x-www-form-urlencoded
- Nodejs学习笔记(十七)--- 浮点运算decimal.js
- 推荐系统实践
- Unity Standard Assets 简介之 Utility
- 二维高斯核函数(python)
- Android中设置Webview支持Cookie
- Git快速入门和常用命令
- Ajax 防止表单重复提交
- 戏说模式之装饰者模式(游戏)