Hi,
I've got a little problem with the WebClient, I always get a failure while
debugging this code:
private void menuItem2_Click(object sender, System.EventArgs e)
{
NameValueCollection values = new NameValueCollection();
values.Add("pptpdisconnect","true");
string got =
UploadValuesToSecureWebsite("http://192.168.0.1/","admin","*******","post",v
alues);
}
public string UploadValuesToSecureWebsite(string URL, string Username,
string Password, string Method, NameValueCollection values)
{
WebClient myWebClient = new WebClient();
NetworkCredential trust = new NetworkCredential(Username,Password);
myWebClient.Credentials = trust;
byte[] Response = myWebClient.UploadValues(URL, Method, values);
string result = Encoding.ASCII.GetString(Response);
return result;
}
Regards, Max - I hope my English was understandable, or even good ;-)
PS: Here, the details about the failure:
at System.Net.ConnectStream.BeginRead(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.WebClient.ResponseAsBytes(WebResponse response)
at System.Net.WebClient.UploadValues(String address, String method,
NameValueCollection data)