下面这段代码提交post数据
  
  
  
  可是提交的数据居然是空的,faint...,即使数据格式不对,总有些数据提交出去吧
  
  哪位高手帮忙看看阿?
  
  
  
  HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  req.Method = “POST“;
  req.ContentType = “application/x-www-form-urlencoded“;
  string paraUrlCoded = ““;
  paraUrlCoded+=HttpUtility.HtmlEncode(“user“) + “=“+HttpUtility.HtmlEncode(this.textBox3.Text)+“&“;
  paraUrlCoded+=HttpUtility.HtmlEncode(“pass“) + “=“ + HttpUtility.HtmlEncode(this.textBox6.Text) + “&“; 
   
  byte[] reqData = Encoding.UTF8.GetBytes(paraUrlCoded);
  req.ContentLength = reqData.Length;
  Stream writer = req.GetRequestStream ();
  writer.Write(reqData,0,reqData.Length);
  writer.Close();

解决方案 »

  1.   

    其实准确的说是根本没有POST这个动作…………请各位高手指点一二……
      

  2.   

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
      req.Method = "POST";
      req.ContentType = "application/x-www-form-urlencoded";
      string paraUrlCoded = "";
      paraUrlCoded+=HttpUtility.HtmlEncode("user") + "="+HttpUtility.HtmlEncode(this.textBox3.Text)+"&";
      paraUrlCoded+=HttpUtility.HtmlEncode("pass") + "=" + HttpUtility.HtmlEncode(this.textBox6.Text) + "&"; 
       
      byte[] reqData = Encoding.UTF8.GetBytes(paraUrlCoded);
      req.ContentLength = reqData.Length;
      Stream writer = req.GetRequestStream ();
      writer.Write(reqData,0,reqData.Length);
      writer.Close();不小心把代码的引号变成中文符号了,现在重贴一次…………请高手指点一二…………
      

  3.   

    这方面的没做过,不过以前好像看到过另外的实现方法,用WebClient