【问题标题】:Not calling Response.Flush still sends Connection: Close in the Response不调用 Response.Flush 仍然在响应中发送 Connection: Close
【发布时间】:2011-04-19 20:33:05
【问题描述】:

我的印象是不调用 Response.Flush 将确保不会返回 Connection: Close。那么如何返回 Connection: 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

【问题讨论】:

    标签: c# asp.net http connection keep-alive


    【解决方案1】:

    我不确定您是否可以发送连接:Keep-Alive 与开发服务器。

    您可以通过浏览到 IIS 管理器中的“HTTP 响应标头”部分并单击右侧的“设置公共标头...”操作在 IIS7 中进行设置。

    【讨论】:

      猜你喜欢
      • 2015-05-15
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2019-12-16
      • 2012-12-31
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多