How To Create Default Website In Iis
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Default Settings for All Sites <siteDefaults>
- Article
- 5 minutes to read
Thank you.
Overview
The <siteDefaults> element specifies default settings for all sites on the server. These settings are useful when you want to specify options for all Web sites that differ from the schema defaults for IIS 7 and later.
Note
If the same attribute or child element is configured in both the <siteDefaults> section and in the <sites> section for a specific site, the configuration in the <sites> section is used for that site.
Compatibility
| Version | Notes |
|---|---|
| IIS 10.0 | The <siteDefaults> element was not modified in IIS 10.0. |
| IIS 8.5 | The <siteDefaults> element was not modified in IIS 8.5. |
| IIS 8.0 | The <siteDefaults> element was not modified in IIS 8.0. |
| IIS 7.5 | The <siteDefaults> element was not modified in IIS 7.5. |
| IIS 7.0 | The <siteDefaults> element of the <sites> element was introduced in IIS 7.0. |
| IIS 6.0 | The <siteDefaults> element is analogous to the default Web site options at the W3SVC level in the IIS 6.0 metabase. |
Setup
The <siteDefaults> element of the <sites> element is included in the default installation of IIS 7 and later.
How To
How to configure the site defaults 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, 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 options for all Web sites, and then click OK.
Configuration
Attributes
| Attribute | Description |
|---|---|
id | Optional uint attribute. Specifies the random numeric identifier that is assigned by IIS when the site is created. The default Web site is numbered 1. Other Web sites server-assigned numbers that may be composed of multiple digits. |
name | Optional string attribute. Specifies a friendly name that uniquely identifies a Web site, for example, "Contoso HR Forms." |
serverAutoStart | Optional Boolean attribute. Specifies whether the site should start automatically when the Management Service is started. The default value is |
Child Elements
| Element | Description |
|---|---|
bindings | Optional element. Specifies default bindings for access to sites. |
ftpServer | Optional element. Specifies default settings for FTP sites. Note: This requires installing FTP 7.0 or FTP 7.5. |
limits | Optional element. Configures default settings to limit the amount of bandwidth, the number of connections, or the amount of time for connections to sites. |
logFile | Optional element. Configures default settings for handling and storage of log files for sites. |
traceFailedRequestsLogging | Optional element. Specifies default settings for logging failed-request traces for sites. |
Configuration Sample
The following configuration sample specifies the default limits, logFile, traceFailedRequestsLogging, bindings, and ftpServer options for IIS 7.
<system.applicationHost> <sites> <siteDefaults> <logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" enabled="true" /> <traceFailedRequestsLogging enabled="true" directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" maxLogFiles="20" /> <limits connectionTimeout="00:01:00" /> <ftpServer serverAutoStart="true" /> <bindings> <binding protocol="http" bindingInformation="127.0.0.1:8080:" /> </bindings> </siteDefaults> </sites> </system.applicationHost> Sample Code
The following code samples configure the default limits, logFile, traceFailedRequestsLogging, bindings, and ftpServer options for IIS 7.
AppCmd.exe
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.connectionTimeout:"00:02:00" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.enabled:"True" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.logFormat:"W3C" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.directory:"%SystemDrive%\inetpub\logs\LogFiles" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.enabled:"True" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.directory:"%SystemDrive%\inetpub\logs\FailedReqLogFiles" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.maxLogFiles:"20" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.bindings.[protocol='http',bindingInformation='*:8080:contoso.com'].bindingInformation:"127.0.0.1:8080:" /commit:apphost appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.serverAutoStart:"True" /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:02:00"); ConfigurationElement logFileElement = siteDefaultsElement.GetChildElement("logFile"); logFileElement["logFormat"] = @"W3C"; logFileElement["directory"] = @"%SystemDrive%\inetpub\logs\LogFiles"; logFileElement["enabled"] = true; ConfigurationElement traceFailedRequestsLoggingElement = siteDefaultsElement.GetChildElement("traceFailedRequestsLogging"); traceFailedRequestsLoggingElement["enabled"] = true; traceFailedRequestsLoggingElement["directory"] = @"%SystemDrive%\inetpub\logs\FailedReqLogFiles"; traceFailedRequestsLoggingElement["maxLogFiles"] = 20; ConfigurationElementCollection bindingsCollection = siteDefaultsElement.GetCollection("bindings"); ConfigurationElement bindingElement = bindingsCollection.CreateElement("binding"); bindingElement["protocol"] = @"http"; bindingElement["bindingInformation"] = @"127.0.0.1:8080:"; bindingsCollection.Add(bindingElement); ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer"); ftpServerElement["serverAutoStart"] = true; 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:02:00") Dim logFileElement As ConfigurationElement = siteDefaultsElement.GetChildElement("logFile") logFileElement("logFormat") = "W3C" logFileElement("directory") = "%SystemDrive%\inetpub\logs\LogFiles" logFileElement("enabled") = True Dim traceFailedRequestsLoggingElement As ConfigurationElement = siteDefaultsElement.GetChildElement("traceFailedRequestsLogging") traceFailedRequestsLoggingElement("enabled") = True traceFailedRequestsLoggingElement("directory") = "%SystemDrive%\inetpub\logs\FailedReqLogFiles" traceFailedRequestsLoggingElement("maxLogFiles") = 20 Dim bindingsCollection As ConfigurationElementCollection = siteDefaultsElement.GetCollection("bindings") Dim bindingElement As ConfigurationElement = bindingsCollection.CreateElement("binding") bindingElement("protocol") = "http" bindingElement("bindingInformation") = "127.0.0.1:8080:" bindingsCollection.Add(bindingElement) Dim ftpServerElement As ConfigurationElement = siteDefaultsElement.GetChildElement("ftpServer") ftpServerElement("serverAutoStart") = true 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:02:00"; var logFileElement = siteDefaultsElement.ChildElements.Item("logFile"); logFileElement.Properties.Item("logFormat").Value = "W3C"; logFileElement.Properties.Item("directory").Value = "%SystemDrive%\\inetpub\\logs\\LogFiles"; logFileElement.Properties.Item("enabled").Value = true; var traceFailedRequestsLoggingElement = siteDefaultsElement.ChildElements.Item("traceFailedRequestsLogging"); traceFailedRequestsLoggingElement.Properties.Item("enabled").Value = true; traceFailedRequestsLoggingElement.Properties.Item("directory").Value = "%SystemDrive%\\inetpub\\logs\\FailedReqLogFiles"; traceFailedRequestsLoggingElement.Properties.Item("maxLogFiles").Value = 20; var bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection; var bindingElement = bindingsCollection.CreateNewElement("binding"); bindingElement.Properties.Item("protocol").Value = "http"; bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:"; bindingsCollection.AddElement(bindingElement); var ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer"); ftpServerElement.Properties.Item("serverAutoStart").Value = true; 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:02:00" Set logFileElement = siteDefaultsElement.ChildElements.Item("logFile") logFileElement.Properties.Item("logFormat").Value = "W3C" logFileElement.Properties.Item("directory").Value = "%SystemDrive%\inetpub\logs\LogFiles" logFileElement.Properties.Item("enabled").Value = True Set traceFailedRequestsLoggingElement = siteDefaultsElement.ChildElements.Item("traceFailedRequestsLogging") traceFailedRequestsLoggingElement.Properties.Item("enabled").Value = True traceFailedRequestsLoggingElement.Properties.Item("directory").Value = "%SystemDrive%\inetpub\logs\FailedReqLogFiles" traceFailedRequestsLoggingElement.Properties.Item("maxLogFiles").Value = 20 Set bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection Set bindingElement = bindingsCollection.CreateNewElement("binding") bindingElement.Properties.Item("protocol").Value = "http" bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:" bindingsCollection.AddElement(bindingElement) Set ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer") ftpServerElement.Properties.Item("serverAutoStart").Value = True adminManager.CommitChanges() How To Create Default Website In Iis
Source: https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/sitedefaults/
Posted by: leehaturat.blogspot.com

0 Response to "How To Create Default Website In Iis"
Post a Comment