Search code examples
c#authenticationwebrequest

Using HTTP Authentication with a C# WebRequest


I want to make a web request to a page that needs authenticating. How would I go about doing this? I found something that said possibly to use the Credentials property, but I'm not sure how to use it.


Solution

  • Assign a new NetworkCredential instance to the Credentials property:

    webClient.Credentials = new NetworkCredential("Mehrdad", "Password");