我正在尝试使用 C# 中的 WebClient 发布到网页。不知何故,参数没有通过。该页面本身是一个 php 页面。我已经使用常规浏览器/html 页面测试了同一页面,然后它可以工作,所以我期待这是一个客户端问题
谁能告诉我我可能做错了什么?
WebClient myClient = new WebClient();
myClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
try
{
NameValueCollection keyvaluepairs = new NameValueCollection();
keyvaluepairs.Add("request", "foo");
byte[] responseArray = myClient.UploadValues("http://www.motio.com/test.php?id=7", "POST", keyvaluepairs);
string response = Encoding.ASCII.GetString(responseArray);
}
catch (Exception e)
{
}