title: C# - passing authentication credentials with HttpWebRequest
body: <p>I am working on a tool that parses html source of given urls. Some of them are password protected. </p>
  
  <p>Here is my question: How can I pass authentication credentials with the HttpWebRequest? Does it require setting up a cookie?
  These are new grounds to me, thus examples would be very helpful.</p>
  
  <p>In summary, I use the following for requests that not require an authentication.</p>
  
  <pre><code>...
  HttpWebRequest request =(HttpWebRequest)WebRequest.Create(HttpUtility.UrlDecode(&lt;URL   STRING&gt;));
  ...
  HttpWebResponse response =(HttpWebResponse)request.GetResponse();
  </code></pre>