代码之家  ›  专栏  ›  技术社区  ›  Patrick McDonald

不打电话响应。刷新仍然发送连接:在响应中关闭

  •  1
  • Patrick McDonald  · 技术社区  · 14 年前

    我的印象是响应。刷新将确保不会返回Connection:Close。那么我该如何返回连接:Keep Alive?

    我使用以下代码从ASP.NET.

    Response.ContentType = type;
    Response.AppendHeader("Content-Length", bytes.Length.ToString());
    Response.Cache.SetCacheability(HttpCacheability.Public);
    Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
    Response.Cache.SetExpires(expiryDate);
    Response.Cache.SetLastModifiedFromFileDependencies();
    Response.Cache.SetETag(etag);
    Response.OutputStream.Write(bytes, 0, bytes.Length);
    

    它生成的响应是:

    HTTP/1.1 200 OK
    Server: ASP.NET Development Server/9.0.0.0
    Date: Fri, 01 Oct 2010 12:50:17 GMT
    X-AspNet-Version: 2.0.50727
    X-AspNetMvc-Version: 2.0
    Content-Length: 34808
    Cache-Control: public, must-revalidate
    Expires: Fri, 01 Oct 2010 12:51:17 GMT
    Last-Modified: Wed, 22 Sep 2010 16:00:33 GMT
    ETag: "302E7A7D0D9DA91BABB53F6B6FE0B005"
    Content-Type: image/gif
    Connection: Close
    
    1 回复  |  直到 14 年前
        1
  •  1
  •   Rex Morgan    14 年前

    我不确定您是否可以发送connection:Keep Alive with the development server。

    您可以在IIS7中设置它,方法是浏览到iismanager中的“HTTP响应头”部分,然后单击右侧的“设置公共头…”操作。