The <applicationDefaults> element of the <sites> element specifies the default application settings for all applications on the server.
Note: If the same attribute or child element is configured in both the <applicationDefaults> section and in the <application> section for a specific application, the configuration in the <application> section is used for that application.
| |
IIS 7.0 |
IIS 6.0 |
| Notes |
The <applicationDefaults> element of the <sites> element is new in IIS 7.0. |
The <applicationDefaults> element is analogous to setting setting application options at the W3SVC level in the IIS 6.0 metabase. |
The <applicationDefaults> element of the <sites> element is included in the default installation of IIS 7.0.
How to configure the default application settings for a server
- On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
- In the Connections pane, expand the server name, then click the Sites node.
- In the server's Sites pane, click Set Web Site Defaults... in the Actions pane.
- In the Web Site Defaults dialog box, specify your default application settings for all Web sites, and then click OK.
Attributes
| Attribute |
Description |
applicationPool |
Optional string attribute.
Specifies the default application pool to which all applications on the server are assigned. |
enabledProtocols |
Optional string attribute.
Specifies the protocols to use to communicate with all applications on the server. |
path |
Optional string attribute.
Specifies the default virtual path of all applications on the server. |
Child Elements
None.
Configuration Sample
The following configuration sample sets the default application pool for all Web sites to "DefaultAppPool".
<system.applicationHost>
<sites>
<applicationDefaults applicationPool="DefaultAppPool" />
</sites>
</system.applicationHost>
The following code samples set the default application pool for all Web sites to "DefaultAppPool".
AppCmd.exe
appcmd.exe set config -section:system.applicationHost/sites /applicationDefaults.applicationPool:"DefaultAppPool" /commit:apphost
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 applicationDefaultsElement = sitesSection.GetChildElement("applicationDefaults");
applicationDefaultsElement["applicationPool"] = @"DefaultAppPool";
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 applicationDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("applicationDefaults")
applicationDefaultsElement("applicationPool") = "DefaultAppPool"
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 applicationDefaultsElement = sitesSection.ChildElements.Item("applicationDefaults");
applicationDefaultsElement.Properties.Item("applicationPool").Value = "DefaultAppPool";
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 applicationDefaultsElement = sitesSection.ChildElements.Item("applicationDefaults")
applicationDefaultsElement.Properties.Item("applicationPool").Value = "DefaultAppPool"
adminManager.CommitChanges()