HTTP Protocol Settings <httpProtocol>


The <httpProtocol> element configures HTTP keep-alive connections as well as both custom and redirect response headers that Internet Information Services (IIS) 7 sends to Web clients.

A browser typically makes multiple requests in order to download an entire Web page. To enhance server performance, most Web browsers request that the server keep the connection open across these multiple requests, which is a feature known as HTTP keep-alives. Without HTTP keep-alives, a browser that makes many requests for a page containing multiple elements, such as graphics, might require a separate connection for each element. These additional requests and connections require extra server activity and resources, decreasing server efficiency. The additional connections also make a browser much slower and less responsive, especially across a slow connection.


Version Notes
IIS 7.5 The <httpProtocol> element was not modified in IIS 7.5.
IIS 7.0 The <httpProtocol> element was introduced in IIS 7.0.
IIS 6.0 The allowKeepAlive attribute of the <httpProtocol> element replaces the IIS 6.0 AllowKeepAlive metabase property.


The <httpProtocol> element is included in the default installation of IIS 7.

How To

How to enable HTTP keep-alives for a Web site or application

  1. Open Internet Information Services (IIS) Manager:
    • If you are using Windows Server 2008 or Windows Server 2008 R2:
      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:
      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. In the Connections pane, go to the site, application, or directory for which you want to enable HTTP keep-alives.
  3. In the Home pane, double-click HTTP Response Headers.

  4. In the HTTP Response Headers pane, click Set Common Headers... in the Actions pane.

  5. In the Set Common HTTP Response Headers dialog box, check the box to enable HTTP keep-alives, and then click OK.



Attribute Description
allowKeepAlive Optional Boolean attribute.

Specifies whether keep-alive processing is permitted (true) or not (false).

The default value is true.

Child Elements

Element Description
customHeaders Configures custom response headers that are returned in responses from the Web server.
redirectHeaders Configures response headers that are returned in responses only when the Web server redirects requests.

Configuration Sample

The following code samples enable HTTP keep-alives for the Default Web Site.

      <httpProtocol allowKeepAlive="true" />

Note: The following default <httpProtocol> element is configured in the ApplicationHost.config file in IIS 7.

      <clear />
      <add name="X-Powered-By" value="ASP.NET" />
      <clear />

Sample Code

The following code samples enable HTTP keep-alives for the Default Web Site.


appcmd.exe set config "Default Web Site" -section:system.webServer/httpProtocol /allowKeepAlive:"True"


using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
   private static void Main()
      using (ServerManager serverManager = new ServerManager())
         Configuration config = serverManager.GetWebConfiguration("Default Web Site");

         ConfigurationSection httpProtocolSection = config.GetSection("system.webServer/httpProtocol");
         httpProtocolSection["allowKeepAlive"] = true;



Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetWebConfiguration("Default Web Site")

      Dim httpProtocolSection As ConfigurationSection = config.GetSection("system.webServer/httpProtocol")
      httpProtocolSection("allowKeepAlive") = True

   End Sub

End Module


var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site";

var httpProtocolSection = adminManager.GetAdminSection("system.webServer/httpProtocol", "MACHINE/WEBROOT/APPHOST/Default Web Site");
httpProtocolSection.Properties.Item("allowKeepAlive").Value = true;



Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site"

Set httpProtocolSection = adminManager.GetAdminSection("system.webServer/httpProtocol", "MACHINE/WEBROOT/APPHOST/Default Web Site")
httpProtocolSection.Properties.Item("allowKeepAlive").Value = True

Deprecated Elements