views:

33

answers:

1

I was under the impression that not calling Response.Flush would ensure that Connection: Close would not be returned. So how do I return Connection: Keep-Alive?

I am using the following code to return a file from 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);

The Response this generates is:

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  A: 

I'm not sure that you can send connection: Keep-Alive with the development server.

You can set it in IIS7 by browsing to the "HTTP Response Headers" section in IIS Manager and click the "Set Common Headers..." action on the right.

RexM