【www.gdgbn.com--邮件处理】

post方法访问站点,要注意的是:post一定要是大写,不然报403错误.
对于aspx网页一定要注意viewstate,如果不post viewstate,后台程序是不会处理的.

HttpWebRequest myHttpWebRequest =
    (HttpWebRequest)WebRequest.Create("http://192.168.31.20/action/WebForm1.aspx");
   myHttpWebRequest.Method="POST";
   string postData="TextBox1="+textBox1.Text;
   System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
   byte[]  byte1=encoding.GetBytes(postData);
     myHttpWebRequest.ContentType="application/x-www-form-urlencoded";
    myHttpWebRequest.ContentLength=postData.Length;
   System.IO.Stream newStream;
    newStream=myHttpWebRequest.GetRequestStream();
    newStream.Write(byte1,0,byte1.Length);
      newStream.Close();
   System.Net.WebResponse wResp =myHttpWebRequest.GetResponse();
   System.IO.Stream respStream  = wResp.GetResponseStream();
   System.IO.StreamReader reader = new System.IO.StreamReader(respStream,

    System.Text.Encoding.GetEncoding("gb2312"));
   textBox2.Text=reader.ReadToEnd();
   respStream.Close();
   reader.Close();



本文来源:http://www.gdgbn.com/jiaocheng/13012/