.net发送HTTP POST包

         StreamReader sr = null;
                 StreamWriter sw = null;
                 HttpWebResponse wr = null;
                 string strpostdata = "__VIEWSTATE=%2FwEPDwUKMTc0MzU1MDk5NWRkmk%2BVYLo6b5Aae4hUx%2FS64n3zQVI%3D&wk36=98&Button1=%CC%E1%BD%BB&inum=a6a0612c-1545735141&__EVENTVALIDATION=%2FwEWAgK%2Fn9K6BgKM54rGBvT1bQkNrIQwJz4Om78sErwHjml%2B";

                 HttpWebRequest hp = (HttpWebRequest)WebRequest.Create(@"http://myhero.smgbb.cn/baoming/tennis.aspx");
                 hp.Method = "POST";
                 hp.ContentType = "application/x-www-form-urlencoded";
                 hp.ContentLength = strpostdata.Length;

                 sw = new StreamWriter(hp.GetRequestStream());
                 sw.Write(strpostdata);
                 sw.Flush();

                 wr = (HttpWebResponse)hp.GetResponse();
                 sr = new StreamReader(wr.GetResponseStream());

                 sw.Close();
                 sr.Close();
                 wr.Close();

posted @ 2008-12-19 15:55  肚肚  阅读(354)  评论(0编辑  收藏  举报