POST请求
来源:互联网 发布:js比较值 编辑:程序博客网 时间:2024/06/06 00:16
1、设置请求对象(并设置请求地址、方式、类型、长度。)
注:地址中包含所请求的方法名称,该请求如果该请求是无参数请求,则长度设置为 0
WebRequest request = WebRequest.Create(url + "getBaseData");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
//request.ContentType = "text/html;charset=UTF-8";
request.ContentLength = postData.Length;
2、(本步骤为有参请求设置)设置参数写入流
StreamWriter sw = new StreamWriter(request.GetRequestStream());
sw.Write(postData);
sw.Flush();
3、设置响应对象
WebResponse response = request.GetResponse();
4、响应数据存入读取流中,并读取。
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.GetEncoding("UTF-8"));
5、关闭流、释放空间
sw.Dispose();
sw.Close();
sr.Dispose();
sr.Close();
s.Dispose();
s.Close();
阅读全文
0 0
- post请求
- POST请求
- POST请求
- POST请求
- post请求
- POST请求
- post请求
- POST请求
- post请求
- post 请求
- post请求
- post请求
- POST请求
- POST请求
- post请求
- post请求
- post请求
- post请求
- ajax提交整个form表单
- 关于华硕主板“USB Devices Over Current Status Detected!”
- spring boot 官方文档翻译之 配置log4j
- 搭建hadood2.8.0集群开发环境
- LESS CSS 框架简介
- POST请求
- WAVE PCM soundfile format
- Chapter3:字符串编码和文件操作
- kotlin-Android
- Codeforces Round #414
- 封装jQuery
- 关于ajaxfileupload file 的change事件 只绑定一次,
- Android线程—买票demo
- sql去掉空格