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

错误:远程服务器返回错误: (405) 不允许的方法。
byte[] buffer = Encoding.ASCII.GetBytes("TextBox1=admin&TextBox2=admin");
  HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://127.0.0.1");
  WebReq.Method = "post";
  WebReq.ContentType = "application/x-www-form-urlencoded";
  WebReq.ContentLength = buffer.Length;
  Stream PostData = WebReq.GetRequestStream();
  PostData.Write(buffer, 0, buffer.Length);
  PostData.Close();
  HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
  richTextBox1.Text = WebResp.StatusCode.ToString();
  richTextBox1.Text += "\n\n\n\n\n";
  richTextBox1.Text += WebResp.Server;

  Stream Answer = WebResp.GetResponseStream();
  StreamReader _Answer = new StreamReader(Answer);
  richTextBox1.Text += "\n\n\n" + _Answer.ReadToEnd();

报错:远程服务器返回错误: (405) 不允许的方法。
该如何解决

------解决方案--------------------
up