c# - IWebBrowserApp.Navigate() How to send Post Data -
I would be very happy if someone could show me a good example of how to send postal data with the navigating method. Available from SHDocVw.IWebBrowserApp
.
Consider for example.
We should have gone to the page:
And the values of the named input field should be sent to: Username and password.
Edit
I'm trying to get native Internet Explorer version 7 or higher with my C # app, available on Windows OS, a specific To send an HTTP request to the URL, the HTTP response handling the server side page using a user's username and password. With the IWebBrowserApp and navigated
method, I am able to open a new window / Internet Explorer instance and it can be found on a specific page (local or web ), And then specify POST data and custom headers
but the main problem is that I do not know how to write your data in the POST request made by the browser.
I would appreciate the help.
How did I get an order for IE to open web pages and send some POST data?
-
Add the COM reference to the project named Microsoft Internet Explorer Control .
-
Then
post string
with the field and its value to& amp; Separated by
, and then astring
to abyte array
. -
And finally requested to navigate IE to
url
, and convert the post data to abyte
goes here:
using SHDocVw; // Internet Explorer IEControl = Do not forget the new Internet Explorer; IWebBrowserApp IE = (IWebBrowserApp) IEControl; IE.Visible = true; Convert // string to a byte array ASCIIEncoding encode = new ASCIIEncoding (); Byte [] Post = Encoded Getbytes ("Username = Fabio and password = 123"); // Destination url string url = "http://example.com/check.php"; // The same header that you submitted a form. String posthoders = "content-type: app / x-www-form-urxed"; IE.Navigate (url, blank, blank, post, post headers);
Note:Do not forget to try to do this work that your server side page Write / echo will be the name given field: username and password.
PHP code example:
& lt ;? Php echo $ _POST ['username']; Echo ""; Copy $ _POST ['password']; ? & Gt;
ASP code example:
& lt;% response.write (Request.Form ("username")) reaction. Write ("" and request.form ("password"))%>
Comments
Post a Comment