Search code examples
authenticationhttpwebrequestnetworkcredentials

Forms Authentication and HttpWebRequest


I need to be able to login to a site via Forms Authentication using a HttpWebRequest.

Currently, when I provide NetworkCreditials to the request, it just redirects me to the Login page, which makes sense...but how do I go about ensuring that the request correctly authenticates without redirecting?

Thanks


Solution

  • If the site uses cookies to tracks users you need to use a cookie container in order to store the authentication cookie emitted by the server and reuse this cookie in later requests to access authenticated parts of the site.