Use Webbrowser control to get and post data?

筅森魡賤 提交于 2020-01-31 05:27:44

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32837084/use-webbrowser-control-to-get-and-post-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!