Sending POST form with WebBrowser

  • Thread starter Thread starter sweetiecakes
  • Start date Start date
S

sweetiecakes

After a brief Google session, I can only find the following:

1. Instructions for pre-.NET VB
2. Other IE controls

I need to send a POST form with the web browser control: I need to do it
with it, because I need "silent authentication" to the website with IE.
How would I do this?
 
sweetiecakes said:
After a brief Google session, I can only find the following:

1. Instructions for pre-.NET VB
2. Other IE controls

I need to send a POST form with the web browser control: I need to do it
with it, because I need "silent authentication" to the website with IE.
How would I do this?

I did this recently, but kind of "hackish" and I'm not sure this was even
the right way. After digging and not finding anything either, I found out
that you can navigate all the elements of the page on the page load event.
So I found all the fields I needed to fill in, then found the submit button
and invoked that click event for that button. It's been working for about a
year without any issues so far.
 
Aaron Smith said:
I did this recently, but kind of "hackish" and I'm not sure this was even
the right way. After digging and not finding anything either, I found out
that you can navigate all the elements of the page on the page load event.
So I found all the fields I needed to fill in, then found the submit
button and invoked that click event for that button. It's been working for
about a year without any issues so far.

Untested idea: Cant you just connect to the webserver using sockets/stream,
send the login info then write the returned cookie to the IE folder &
startup/refresh IE?

The string- to send to the webserver would be like:
strPostLogin "POST /login.php HTTP/1.1" & vbcrlf & "Host: yoursite.com" &
vbcrlf & "Content-Type: application/x-www-form-urlencoded" & vbcrlf &
"Content-Length: 42" & vbcrlf & "user=onlyme&pass=youdontwannadoitlikethat!"
& vbcrlf & vcrlf
 
Trammel said:
Untested idea: Cant you just connect to the webserver using
sockets/stream, send the login info then write the returned cookie to the
IE folder & startup/refresh IE?

The string- to send to the webserver would be like:
strPostLogin "POST /login.php HTTP/1.1" & vbcrlf & "Host: yoursite.com" &
vbcrlf & "Content-Type: application/x-www-form-urlencoded" & vbcrlf &
"Content-Length: 42" & vbcrlf &
"user=onlyme&pass=youdontwannadoitlikethat!" & vbcrlf & vcrlf

That might be very possible. I didn't even think of doing that when I did
what I had to do. It's worth exploring further.
 
That might be very possible. I didn't even think of doing that when I did
what I had to do. It's worth exploring further.

Have you looked at System.Net.WebClient?

Tom Shelton
 
Back
Top