1

I'm creating universal application and I need to use Keep-Alive connection header for my requests. I have the code

using (var client = new System.Net.Http.HttpClient())
{
    client.DefaultRequestHeaders.Add("connection", "Keep-Alive");
    var str = await client.GetStringAsync(uri);
    return str;
}

but I catch exception The header Connection has an empty value. Please somebody show me where is my mistake and how I can set Connection header to Keep-Alive

I've added screenshot from Wireshark where you can see Connection header value by default (if remove client.DefaultRequestHeaders.Add("connection", "Keep-Alive");)

Connection header by default

R.Titov
  • 3,115
  • 31
  • 35
  • You should better clarify what stack are you using, `System.Net.Http` or `Windows.Web.Http`? – kiewic Nov 10 '14 at 17:13

1 Answers1

1

Windows.Web.Http.HttpClient requests are Keepp-Alive by default.

kiewic
  • 15,852
  • 13
  • 78
  • 101