Default Limits for Web Sites <limits>
Overview
The <limits>
element of the <siteDefaults>
element configures default settings that limit the amount of bandwidth, the number of connections, or the connection time-out for client requests for a Web server.
Note
If the <limits>
element is configured in both the <siteDefaults>
section and in the <site>
section for a specific site, the configuration in the <site>
section is used for that site.
Compatibility
Version | Notes |
---|---|
IIS 8.5 | The <limits> element was not modified in IIS 8.5. |
IIS 8.0 | The <limits> element was not modified in IIS 8.0. |
IIS 7.5 | The <limits> element was not modified in IIS 7.5. |
IIS 7.0 | The <limits> element of the <siteDefaults> element was introduced in IIS 7.0. |
IIS 6.0 | The <limits> element replaces the following IIS 6.0 metabase settings:
|
Setup
The <limits>
element of the <siteDefaults>
element is included in the default installation of IIS 7 and later.
How To
How to configure the default connection limit options for a server
Open Internet Information Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
- On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
- Hold down the Windows key, press the letter X, and then click Control Panel.
- Click Administrative Tools, and then double-click 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.
In the Connections pane, and then click the Sites node.
In the Sites pane, click Set Web Site Defaults... in the Actions pane.
In the Web Site Defaults dialog box, expand Limits, specify limit options, and then click OK.
Configuration
Attributes
Attribute | Description |
---|---|
connectionTimeout |
Optional timeSpan attribute. Specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive. Connections can be considered inactive for the following reasons:
00:02:00 (two minutes). |
maxBandwidth |
Optional uint attribute. Specifies the maximum network bandwidth, in bytes per second, that is used for a site. Use this setting to help prevent overloading the network with IIS activity. The default value is 4294967295 . |
maxConnections |
Optional uint attribute. Specifies the maximum number of connections for a site. Use this setting to limit the number of simultaneous client connections. The default value is 4294967295 . |
maxUrlSegments |
Optional uint attribute. Specifies the maximum number of segments permitted in a Url. The default value is 32 . |
Child Elements
None.
Configuration Sample
The following configuration sample specifies the default limits
options for IIS 7 and later.
<system.applicationHost>
<sites>
<siteDefaults>
<limits connectionTimeout="00:02:00" />
</siteDefaults>
</sites>
</system.applicationHost>
Sample Code
The following code samples configure the default limits
options for IIS 7 and later with a connectionTimeout
of 3 minutes.
AppCmd.exe
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.connectionTimeout:"00:03:00" /commit:apphost
Note
You must be sure to set the commit parameter to apphost
when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.
C#
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.GetApplicationHostConfiguration();
ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");
ConfigurationElement limitsElement = siteDefaultsElement.GetChildElement("limits");
limitsElement["connectionTimeout"] = TimeSpan.Parse("00:03:00");
serverManager.CommitChanges();
}
}
}
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")
Dim limitsElement As ConfigurationElement = siteDefaultsElement.GetChildElement("limits")
limitsElement("connectionTimeout") = TimeSpan.Parse("00:03:00")
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");
var limitsElement = siteDefaultsElement.ChildElements.Item("limits");
limitsElement.Properties.Item("connectionTimeout").Value = "00:03:00";
adminManager.CommitChanges();
VBScript
Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")
Set limitsElement = siteDefaultsElement.ChildElements.Item("limits")
limitsElement.Properties.Item("connectionTimeout").Value = "00:03:00"
adminManager.CommitChanges()