winfrom post 向服务器请求数据
来源:互联网 发布:java开源投票系统 编辑:程序博客网 时间:2024/06/04 18:26
- public void PostMoths()
- {
- string strURL = "http://www.cqjg.gov.cn/newwww/c7/clwz.asp";
- System.Net.HttpWebRequest request;
- request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
- //Post请求方式
- request.Method = "POST";
- //内容类型
- request.ContentType = "application/x-www-form-urlencoded";
- //参数经过URL编码
- string paraUrlCoded = System.Web.HttpUtility.UrlEncode("LicenseTxt");
- paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(txtCarId .Text.Trim());
- paraUrlCoded +="& "+ System.Web.HttpUtility.UrlEncode("VIN");
- paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(txtCarNumber.Text.Trim());
- byte[] payload;
- //将URL编码后的字符串转化为字节
- payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
- //设置请求的ContentLength
- request.ContentLength = payload.Length;
- //获得请求流
- Stream writer = request.GetRequestStream();
- //将请求参数写入流
- writer.Write(payload, 0, payload.Length);
- //关闭请求流
- writer.Close();
- System.Net.HttpWebResponse response;
- //获得响应流
- response = (System.Net.HttpWebResponse)request.GetResponse();
- System.IO.Stream s;
- s = response.GetResponseStream();
- string StrDate = "";
- string strValue = "";
- StreamReader Reader = new StreamReader(s,Encoding.Default);
- while ((StrDate= Reader.ReadLine())!=null)
- {
- strValue += StrDate+"\r\n";
- }
- // txtInfo.Text = strValue;
- txtInfo.Text= FindContent(strValue);
- //XmlTextReader Reader = new XmlTextReader(s);
- //Reader.MoveToContent();
- //string strValue = Reader.ReadInnerXml();
- //strValue = strValue.Replace("<", "<");
- //strValue = strValue.Replace(">", ">");
- //MessageBox.Show(strValue);
- //Reader.Close();
- }
0 0
- winfrom post 向服务器请求数据
- post请求向服务器发送数据
- Android向Web服务器发送Post请求并返回数据
- Android向Web服务器发送Post请求并返回数据
- Android使用HttpURLConnection进行POST请求,向服务器上传数据
- c++ HTTP POST请求 向服务器发送json数据
- libcurl HTTP POST请求向服务器发送json数据
- 模拟向服务器POST数据
- Okhttp 向服务器发送请求(请求头,表单,post json数据)
- NSURLConnection 向服务器发送post请求
- 如何向php服务器发送数据为json的post请求
- Android开发使用POST方式向服务器请求和发送数据
- echarts通过ajax向服务器发送post请求,servlet从数据库读取数据并返回前端
- iOS开发-post请求向服务器发送json格式数据(数组或字典)
- [JQ权威指南]使用全局函数post()向服务器请求数据
- iOS开发-post请求向服务器发送json格式数据(数组或字典)
- 手动get post请求网络(面向http协议向服务器提交数据)
- silverlight向服务器post数据类
- CSS浏览器兼容问题集(一)
- 一线架构师实践指南
- SupremeWord进度35.5%
- php-数据分析 余弦相似度实现
- Hbase配置中出现的问题总结
- winfrom post 向服务器请求数据
- Android自定义进度条
- CSS浏览器兼容问题集(二)
- 赵雅智_ListView_ArrayAdapter
- VelocityTracker的简单使用方法
- JRTPLIB 3.9.1 类大全
- 欧几里德算法
- web前端研发工程师
- ios即时通讯客户端开发之-mac上搭建openfire服务器