如何在httprequest中设置postvar的名称?

时间:2009-09-18 22:07:41

标签: c# post web-services httprequest

我需要联系一个响应战后“数据”的网络服务。 如何使用httprequest在c#中设置此名称... 这就是我得到的:

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

            HttpWebRequest myRequest =
              (HttpWebRequest)WebRequest.Create("http://secreturl/jubidubb.php");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = data.Length;
            myRequest.KeepAlive = true;
            Stream newStream = myRequest.GetRequestStream();


            newStream.Write(data, 0, data.Length);
            newStream.Close();

            // The response
            WebResponse response = myRequest.GetResponse();

1 个答案:

答案 0 :(得分:2)

不响应postvar“数据”只是意味着您的postData字符串必须采用"data=mydata"形式?