title: Programatiically login to a website that uses IIS authentication
body: <p>Hi all am trying to login to a website programmatically.I have already worked on this but is was a php page and i used the below code (found some where on Stack Overflow) to login to it and it worked great. </p>
  
  <pre><code> private static string GetDataFromPHP(string formUrl, string getUrl, string username, string password, out bool status)
          {
  
              try
              {
  
                  string formParams = string.Format("access_login={0}&amp;access_password={1}", username, password);
                  string cookieHeader;
                  WebRequest req = WebRequest.Create(formUrl);
                  req.ContentType = "application/x-www-form-urlencoded";
                  req.Method = "POST";
                  byte[] bytes = Encoding.ASCII.GetBytes(formParams);
                  req.ContentLength = bytes.Length;
                  using (Stream os = req.GetRequestStream())
                  {
                      os.Write(bytes, 0, bytes.Length);
                  }
  
                  WebResponse resp = req.GetResponse();
                  cookieHeader = resp.Headers["Set-cookie"];
                  string pageSource;
  
                  WebRequest getRequest = WebRequest.Create(getUrl);
                  getRequest.Headers.Add("Cookie", cookieHeader);
                  WebResponse getResponse = getRequest.GetResponse();
                  using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
                  {
                      pageSource = sr.ReadToEnd();
                  }
                  status = true;
  
                  return pageSource;
              }
  
  
  
              catch (System.Exception ex)
              {
                  status = false;
                  return string.Empty;
              }
  
          }
  </code></pre>
  
  <p>Where access_login &amp; access_password is the name of the input box that accepts the credentials.I have no clue how to implement it for a iis Login prompt as shown below.Please help</p>
  
  <p><img src="https://i.stack.imgur.com/jyxA6.jpg" alt="enter image description here"></p>