I would be very glad if someone could show me a good example of how to send POST data with the Navigate Method, available through
I've found how to order IE to open a webpage and send some POST data.
Add a COM Reference named Microsoft Internet Explorer Controls to the project.
Then create the
post string with the field and its value separated by
&, and then convert that
string into a
And in the end just had to request IE to Navigate to the
url, and also send the Post Data converted into a
byte array, and then add the same Header that its added when we submit a form.
using SHDocVw; // Don't forget InternetExplorer IEControl = new InternetExplorer(); IWebBrowserApp IE = (IWebBrowserApp)IEControl; IE.Visible = true; // Convert the string into a byte array ASCIIEncoding Encode = new ASCIIEncoding(); byte post = Encode.GetBytes("username=fabio&password=123"); // The destination url string url = "http://example.com/check.php"; // The same Header that its sent when you submit a form. string PostHeaders = "Content-Type: application/x-www-form-urlencoded"; IE.Navigate(url, null, null, post, PostHeaders);
To try if this works. Don't forget that your server side page would have to write/echo the Post fields named: username and password.
PHP Code Example:
<?php echo $_POST['username']; echo " "; echo $_POST['password']; ?>
ASP Code Example:
<% response.write(Request.Form("username")) response.write(" " & Request.Form("password")) %>
And the page would display something like this: