title: C# - Connection: keep-alive Header is Not Being Sent During HttpWebRequest
body: <p>I'm trying to send to send the following header with my HttpWebRequest:</p>
  
  <p><code>Connection: keep-alive</code></p>
  
  <p>However, the header is never sent.  Fiddler2 is showing that whenever I request the page in Google Chrome, the header is sent.  However, my application refuses to send this header for some reason.</p>
  
  <p>I have set the <code>KeepAlive</code> property to <code>true</code> (it's <code>true</code> by default anyway), yet the header still does not get sent.</p>
  
  <p>I am trying to send this header with multiple HttpWebRequests, but they all basically look like this:</p>
  
  <pre><code>HttpWebRequest logIn6 = (HttpWebRequest)WebRequest.Create(new Uri(responseFromLogIn5));
  logIn6.CookieContainer = cookies;
  logIn6.KeepAlive = true;
  logIn6.Referer = "https://login.yahoo.com/config/login?.src=spt&amp;.intl=us&amp;.lang=en-US&amp;.done=http://football.fantasysports.yahoo.com/";
  logIn6.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1";
  logIn6.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  logIn6.Headers.Add("Accept-Encoding:gzip,deflate,sdch");
  logIn6.Headers.Add("Accept-Language:en-US,en;q=0.8");
  logIn6.Headers.Add("Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3");
  logIn6.AllowAutoRedirect = false;
  
  HttpWebResponse logIn6Response = (HttpWebResponse)logIn6.GetResponse();
  string responseFromLogIn6 = logIn6Response.GetResponseHeader("Location");
  
  cookies.Add(logIn6Response.Cookies);
  
  logIn6Response.Close();
  </code></pre>
  
  <p>Does anyone know what I have to do to make sure this header is sent?</p>
  
  <p>Fiddler2 Raw From Chrome:</p>
  
  <pre><code>GET xxx HTTP/1.1
  Host: accounts.google.com
  Connection: keep-alive
  Referer: https://login.yahoo.com/config/login?.src=spt&amp;.intl=us&amp;.lang=en-US&amp;.done=http://football.fantasysports.yahoo.com/
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: en-US,en;q=0.8
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Cookie: xxx
  
  HTTP/1.1 302 Moved Temporarily
  Set-Cookie: xxx
  Set-Cookie: xxx
  Location: xxx
  Content-Type: text/html; charset=UTF-8
  P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&amp;answer=151657 for more info."
  Date: Sat, 17 Sep 2011 22:27:09 GMT
  Expires: Sat, 17 Sep 2011 22:27:09 GMT
  Cache-Control: private, max-age=0
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-XSS-Protection: 1; mode=block
  Content-Length: 2176
  Server: GSE
  </code></pre>
  
  <p>Fiddler2 Raw From My Application:</p>
  
  <pre><code>GET xxx HTTP/1.1
  Referer: https://login.yahoo.com/config/login?.src=spt&amp;.intl=us&amp;.lang=en-US&amp;.done=http://football.fantasysports.yahoo.com/
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: en-US,en;q=0.8
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Host: accounts.google.com
  
  HTTP/1.1 302 Moved Temporarily
  Location: xxx
  Content-Type: text/html; charset=UTF-8
  Date: Sun, 18 Sep 2011 00:05:40 GMT
  Expires: Sun, 18 Sep 2011 00:05:40 GMT
  Cache-Control: private, max-age=0
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-XSS-Protection: 1; mode=block
  Content-Length: 573
  Server: GSE
  </code></pre>
  
  <p>I'm trying to get the second Fiddler2 raw information to look like the first Fiddler2 raw information.</p>