C#UploadString不起作用

时间:2013-11-20 10:00:30

标签: c# .net webclient

WebClient WbClient  = new WebClient();
WbClient.Credentials = new System.Net.NetworkCredential(username,password);
WbClient.Proxy = null;
WbClient.Headers.Add("CIMOperation", "MethodCall");
WbClient.Headers.Add("CIMMethod", "EnumerateInstances");
WbClient.Headers.Add("CIMObject", var1);
WbClient.Headers.Add("Content-Type", "application/xml");
string res =   WbClient.UploadString(new Uri(url),"POST",var2);

url类似http:// 12.144.15.15:2344var2proper xml。服务器在10分钟后返回null。这是什么意思?

1 个答案:

答案 0 :(得分:0)

将XML转换为字符串此方法接受第二个参数(数据类型字符串)作为字符串。

string res =   WbClient.UploadString(new Uri(url),var2); 

MSDN