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

POST传值问题
if (Regex.Match(Phone, @"(13[4-9]|15[8-9]){1}\d{8}").Success)
  {
  //Response.Write("<script>alert('移动!');window.history.back();</script>");
  // return;
  Encoding myEncoding = Encoding.GetEncoding("gb2312");
  string param = HttpUtility.UrlEncode("userid", myEncoding) + "=" + HttpUtility.UrlEncode(Phone, myEncoding) + "&" + HttpUtility.UrlEncode("password", myEncoding) + "=" + HttpUtility.UrlEncode(Msg, myEncoding);

  byte[] postBytes = Encoding.ASCII.GetBytes(param);

  HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://chineseserver.net:3388/CellServer/SmsAPI/UpdatePassword.jsp");
  req.Method = "POST";
  req.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
  req.ContentLength = postBytes.Length;

  using (Stream reqStream = req.GetRequestStream())
  {
  //reqStream.Write
  reqStream.Write(postBytes, 0, postBytes.Length);
  }
  using (WebResponse wr = req.GetResponse())
  {
  //在这里对接收到的页面内容进行处理
  }
  }
值传不过去.这是为什么..哪出错了啊

------解决方案--------------------
用GET的试一下.POST的我没用过..