Keep a http connection alive in C#?

后端 未结 5 733
后悔当初
后悔当初 2021-01-12 00:04

How do i keep a connection alive in C#? I\'m not doing it right. Am i suppose to create an HttpWebRequest obj and use it to go to any URLs i need? i dont see a way to visit

5条回答
  •  不知归路
    2021-01-12 01:00

    If you're using Http 1.1 you shouldn't be using Keep-Alive as the connection is implicitly Keep-Alive.

    The HttpWebRequest.KeepAlive property can be set but if you're sending an Http 1.1 request it will not actually set the header unless you set it to Close.

    Here's another question that has more info: is an HTTP/1.1 request implicitly keep-alive by default?

提交回复
热议问题