首页 C 中通过post发送信息

C 中通过post发送信息

举报
开通vip

C 中通过post发送信息C 中通过post发送信息 C#中通过post发送信息 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; using System.Net; using System.Text; namespace ThumbsLotteryTicket.MyMethond { public class PostXML { /// /// 发送Http ...

C 中通过post发送信息
C 中通过post发送信息 C#中通过post发送信息 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; using System.Net; using System.Text; namespace ThumbsLotteryTicket.MyMethond { public class PostXML { /// /// 发送Http request /// /// 发送的目标地址 /// 发送内容 /// public string PostXml(string url, string strPost) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // request.ContentLength = Encoding.UTF8.GetByteCount(strPost); //request.CookieContainer = cookie; Stream myRequestStream = request.GetRequestStream(); StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("GBK")); myStreamWriter.Write(strPost); myStreamWriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //response.Cookies = cookie.GetCookies(response.ResponseUri); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("UTF-8")); string retString = myStreamReader.ReadToEnd(); myStreamReader.Close(); myResponseStream.Close(); return retString; } } }
本文档为【C 中通过post发送信息】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_511210
暂无简介~
格式:doc
大小:13KB
软件:Word
页数:0
分类:
上传时间:2017-11-14
浏览量:19