winFrom http协议

 public static string GetStringByUrl(string url)
        {
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded";

            HttpWebResponse webResponse = request.GetResponse() as HttpWebResponse;
            using (Stream s = webResponse.GetResponseStream())
            {
                StreamReader reader = new StreamReader(s, Encoding.UTF8);
                return reader.ReadToEnd();
            }
        }
   var result = GetStringByUrl(textBox1.Text.Trim());

 

posted @ 2018-05-25 16:30  你的斗志并没有失去  阅读(104)  评论(0编辑  收藏  举报