Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Webbrowser control to get and post data?

I have a windows form with a webbrowser control. Using this control, I need login to a website, and get and post data.

The login part will remain manually because various headers and cookies and created and stored.

However, is it possible to use the control to send post/get requests?

like image 603
Ivan-Mark Debono Avatar asked Sep 29 '15 06:09

Ivan-Mark Debono


1 Answers

I do something like this and it works for me.

string postData = "value1=" + 1 + "&value2=" + 2 + "&value3=" + 3;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
byte[] bytes = encoding.GetBytes(postData);
string url = "http://www.domain.com/addSomething";
webBrowser1.Navigate(url, string.Empty, bytes, "Content-Type: application/x-www-form-urlencoded"); 

I hope it is of help.

like image 88
HTMLtag Avatar answered Oct 29 '22 06:10

HTMLtag