HTTP get、post请求
2024-10-19 00:24:33
Post请求:
string postData = "user=123&pass=456"; // 要发放的数据
byte[] byteArray = Encoding.UTF8.GetBytes(postData); HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("http://www.abc.com/a.aspx");
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream();
// Send the data.
newStream.Write(byteArray, , byteArray.Length); //写入参数
newStream.Close(); HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
string textResponse = sr.ReadToEnd(); // 返回的数据
接收参数:string a= Request.Form["user"];
最新文章
- 使用ajaxfileupload插件进行Ajax Post 异步提交多个文件
- 为何重写toString方法后会使哈希码能够打印出来
- MyBatis学习笔记(二) 关联关系
- 教育行业SaaS选型 需要注意的三点问题
- 国外一些好用的UX/UI设计工具和资源分享
- Nginx+keepalived做双机热备加tomcat负载均衡
- Quartz.NET学习系列
- PHP 15:异常
- VS2013中使用QT插件后每次重新编译问题
- scanf函数与scanf_s函数
- javascript 函数和作用域(闭包、作用域)(七)
- 【机器学习基础】熵、KL散度、交叉熵
- [转载]EXCEL绝对引用中$A$1、A$1、$A1三个的区别?
- 关于:无法创建链接服务器 ";ORCL"; 的 OLE DB 访问接口 ";OraOLEDB.Oracle"; 的实例 (错误:7302)
- 第一章 Python基本语法
- GUI学习之八——复选框QCheckBox的学习总结
- linux ./configure check your system clock
- WPF 带清除按钮的文字框SearchTextBox
- [Leetcode]315.计算右侧小于当前元素的个数 (6种方法)
- Js_特效