Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted

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.

Posted

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/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebclientclassopenwritetopic.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

  • *Experts*
Posted

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.

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...