c#单纯发送post请求一个URL得到返回值

复制代码
复制代码
            string Url = "";
            string result = "";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
            req.Method = "POST";
            req.ContentLength = 0;//一定要添加这句
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            Stream stream = resp.GetResponseStream();
            //获取内容
            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
            {
                result = reader.ReadToEnd();
            }
复制代码

 

复制代码

 

posted @   yangjingblog  阅读(1067)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示