好记性不如烂笔头。

C#请求URL读取结果

无参数请求方法:

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.mayb.cn");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string str = reader.ReadToEnd();

带参数的Post请求方法

                WebClient wc = new WebClient();
                wc.Headers.Add("Accept-Language", "zh-cn");
                wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("name", "mayb");
                byte[] bytReturn = wc.UploadValues("http://www.mayb.cn/ajax/webservice.asmx/test", "post", nvc);
                wc.Dispose();
                string str = Encoding.GetEncoding("gbk").GetString(bytReturn);