Pascal_c Posted March 31, 2003 Posted March 31, 2003 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 Quote
*Gurus* divil Posted March 31, 2003 *Gurus* Posted March 31, 2003 You might be able to use the WebClient class in combination with the NetworkCredential class to authenticate. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* Volte Posted March 31, 2003 *Experts* Posted March 31, 2003 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. Quote
Pascal_c Posted March 31, 2003 Author Posted March 31, 2003 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 Quote
*Experts* Volte Posted March 31, 2003 *Experts* Posted March 31, 2003 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. Quote
otherside Posted November 26, 2003 Posted November 26, 2003 it works but if the site need to accept cookies there is a problem anyone has any ideas ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.