• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1360
  • Last Modified:

C#: Best way to programmatically log into a secure web form and "surf" several pages using ASPSESSIONID cookie

What is the easiest/best way to authenticate using a simple POST using HTTPS and keep the session alive from page to page?

Some say System.Net.WebClient and some say HttpWebRequest/HttpWebResponse/CookieContainer.

Is there a built-in class that I can instantiate and call GET() and POST() methods on successively and it manages all host session details?
1 Solution
StephanLead Software EngineerCommented:
Best way is to use HttpWebRequest and HttpWebResponse because this is better configurable to your needs than webclient. When your receive the response, read the cookies you have gotten and memberize these so you can create a new request using the existing cookies(sessions). There is the CookieContainer property for this to read this info.

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now