码迷,mamicode.com
首页 > Web开发 > 详细

http请求数据

时间:2016-07-13 00:55:18      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:

        /// <summary>
        /// http请求post数据
        /// </summary>
        /// <param name="postData">数据</param>
        /// <param name="url">url</param>
        private void httppostdata(string postData, string url)
        {
            WebRequest request = WebRequest.Create(url);
            request.Method = "Post";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = string.IsNullOrWhiteSpace(postData) ? 0 : Encoding.UTF8.GetByteCount(postData);
            StreamWriter sw = new StreamWriter(request.GetRequestStream(), new UTF8Encoding(false));
            sw.Write(postData);
            sw.Flush();
            sw.Dispose();
            sw.Close();
        }

http请求数据

标签:

原文地址:http://www.cnblogs.com/change4now/p/5665230.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!