Help with HttpRequest (VB)

Pascal_c

Newcomer
Joined
Mar 28, 2003
Messages
3
Location
Virginia
Help with HttpRequest

Hi all,

I would like to retrieve a web page that requires a username and a password to access (ie. hotmail.com) from a VB form and then retrieve its html code and write it to a textbox on the form.

I'm not sure if I need to use HttpRequest / HttpResponse to accomplish this task. If I do, would you please send me a sample code on how to do it?
Can someone please help me?
Any help or pointers is greatly appreciated.

Thanks.

- pascal
 
You might be able to use the WebClient class in combination with the NetworkCredential class to authenticate.
 
If it's a simple authentication using GET or POST (clear text, that is),
you might be able to use the UploadData method of the WebClient
class. You might need to make it handle cookies that it sends you
though, I don't know.
 
Thank you both for your input.
I've looked up WebClient and it turns out to be close to HttpRequest. In fact, "The WebClient class uses the WebRequest class to provide access to Internet resources." is the quote I got from MSDN.

Unfortunately, I now have a new problem... here's what I mean:
I got this code from MSDN (http://msdn.microsoft.com/library/d...rlrfsystemnetwebclientclassopenwritetopic.asp) and ran it.
It works fine until it tries to write the string I send to the form
(userfield=John&pwdfield=doe).
It comes back to me with the following exception:

"The remote server returned an error: (405) Method Not Allowed."

Any ideas?
Thanks again guys, you've been a great source of help!

- pascal
 
You might be trying to send using the GET method, when it wants
the POST method. You should try using a NameValueCollection to
store your parameters and then passing that to the UploadData
method, along with the "POST" method.
 
Back
Top