Universal app HttpClient header error

407 views Asked by At

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

1

There are 1 answers

0
kiewic On BEST ANSWER

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