日期:2014-05-18  浏览次数:20399 次

紧急求救,还没睡的朋友帮忙看看
ASCIIEncoding   encoding   =   new   ASCIIEncoding();
                string   postData   =   "TextBox1=test ";
              //   postData   +=   ( "&Button2=Cookie ");

                byte[]   data   =   encoding.GetBytes(postData);

                //   Prepare   web   request...
                HttpWebRequest   myRequest   =
                (HttpWebRequest)WebRequest.Create( "http://localhost:1708/test/slogin.aspx ");

                myRequest.Method   =   "POST ";
                myRequest.ContentType   =   "application/x-www-form-urlencoded ";
                myRequest.ContentLength   =   data.Length;
                myRequest.AllowAutoRedirect   =   true;
                Stream   newStream   =   myRequest.GetRequestStream();


                //   Send   the   data.
                newStream.Write(data,   0,   data.Length);
                newStream.Close();

                //   Get   response
                HttpWebResponse   myResponse   =   (HttpWebResponse)myRequest.GetResponse();
                StreamReader   reader   =   new   StreamReader(myResponse.GetResponseStream(),   Encoding.Default);
                string   content   =   reader.ReadToEnd();
                Response.Write(content);


-------------为什么TextBox1=test这个值无法post到目标地址:
http://localhost:1708/test/slogin.aspx

------解决方案--------------------
没什么错误,
-------------为什么TextBox1=test这个值无法post到目标地址:
http://localhost:1708/test/slogin.aspx
估计是你取的时候有问题
还有注意编码问题