When using the post method to access the site, note that post must be in uppercase; otherwise, error 403 is reported.
For aspx web pages, you must pay attention to viewstate. If you do not post viewstate, the background program will not process it.
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 ();