Как установить имя поствара в httprequest? - PullRequest
0 голосов
/ 19 сентября 2009

Мне нужно связаться с веб-сервисом, который отвечает на «данные» postvar. Как мне установить это имя в C # с помощью httprequest ... вот что я получил:

            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 Ответ

2 голосов
/ 19 сентября 2009

Не не отвечает на "данные" postvar просто означает, что ваша строка postData должна иметь форму "data=mydata"?

...