Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27020

VS 2012 I need pro HELP with HTTPClient or HTTPWebRequest!

$
0
0
I'm building a windows application that will connect to a website using private proxies and do stuff on that site. I want to use the new HTTPClient to do that. I have the next scenario for the login part:

Code:

1 - I GET the login page. The login page set a cookie (I need to store that).
2 - In the code of the login page I find some dynamic parameters that I scrape using Regex.
 I create the POST url using the parameters that I scraped and an user and a password.
3 - I use the cookie that the login page stored and  I POST to the website (the created URL).
4 - I receive the content of the response and if the login is done correctly I see in the code a redirect url (the http web request will not follow this redirect!) and a cookie is stored.
5- I scrape the redirect url and I use the cookies stored with the POST and do a GET request to the redirect url. Another final cookie is stored (overwritten the last one)

I have tried to do this with httpwebrequest but after the POST I get the response and when I load that response in a browser I see "your browser has the cookies functionality turned off" so I obviously do not know how to store my cookies and use them with the next request then store the new cookies and use them with the last request ...

Now I try to do all over again with HTTPClient ... does anyone can help me with an example using proxy (with proxy user and proxy password)for all 3 requests an with cookie functionality ??

Please HELP!!!

I do not need links to msdn, I have read A LOT, I have experimented A LOT, I did not sleep in the last 48 hours reading and testing so I'm trying my luck on the forum. May be someone will want to share a working code that do something similar (with HTTPWebRequest or the new HTTPClient) so I can test and find out why my code do not use the first cookie to POST the data (I have serialized the cookie and I know that the response from the first GET is saving the cookie, I save it on my hard drive) ...


EDIT: After some sleep I "discovered" why all the "wonderful" examples of HTTPClient out there are written in C# and why I could not find HTTPClient in my VStudio 2012: HTTPClient do not exist in VB.NET, is only implemented for C# C++and JS ... so please help me with HTTPWebRequests (my initial approach)...
EDIT: strange thing - if I start a project in C# I have httpclient by default and in vb I do not have it, but I was able to install in now in VB using NuGet manager... so there is httpclient support in vb.net after all

Viewing all articles
Browse latest Browse all 27020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>