<system.webServer>

概述

<system.webServer> 元素为 ApplicationHost.config 文件中的 Internet Information Services (IIS) 7 的许多站点级和应用程序级配置设置指定根元素,并包含定义 Web 服务器引擎和模块使用的设置的配置元素。

注意

与在中找到 <system.applicationHost>的设置不同,可以委托元素中的 <system.webServer> 设置。

兼容性

版本 备注
IIS 10.0 <applicationInitialization> 元素未在 IIS 10.0 中修改。
IIS 8.5 <system.webServer>该元素未在 IIS 8.5 中修改。
IIS 8.0 <webSocket>元素<applicationInitialization>作为子元素添加。
IIS 7.5 <system.webServer> 元素未在 IIS 7.5 中修改。
IIS 7.0 <system.webServer> 元素是在 IIS 7.0 中引入的。
IIS 6.0 空值

设置

<system.webServer> 元素包含在 IIS 7 的默认安装中。

操作方式

没有特定于 <system.webServer> 元素的示例。 有关配置元素中 <system.webServer> 找到的设置的示例,请参阅本主题 的配置详细信息 部分中列出的子元素。

配置

元素 <system.webServer> 在ApplicationHost.config文件中定义,尽管元素中的 <system.webServer> 设置可以委托给Web.config文件。

特性

无。

子元素

元素 说明
applicationInitialization 可选元素。

为在收到请求之前主动执行的应用程序初始化配置设置。
asp 可选元素。

配置 Active Server Pages (ASP) 应用程序的设置。
caching 可选元素。

配置输出缓存设置。
cgi 可选元素。

为通用网关接口 (CGI) 应用程序配置默认设置。
defaultDocument 可选元素。

在客户端未在请求中指定文件名时,配置用于将默认文档返回到客户端浏览器的设置。
directoryBrowse 可选元素。

配置是否在 Web 服务器上启用或禁用目录浏览,并指定要包含在目录列表中的信息。
fastCgi 可选元素。

包含 fastCgi 应用程序池定义的集合。
globalModules 可选元素。

指定 Web 服务器上的全局模块的配置设置。
handlers 可选元素。

指定处理对站点和应用程序发出的请求的处理程序。
httpCompression 可选元素。

为 Web 服务器配置 HTTP 压缩设置。
httpErrors 可选元素。

为 Web 服务器配置 HTTP 错误消息。
httpLogging 可选元素。

指定HTTP.sys日志记录的配置设置。
httpProtocol 可选元素。

配置要从服务器发送到客户端的自定义和重定向响应标头。
httpRedirect 可选元素。

配置用于将客户端请求重定向到新位置的设置。
httpTracing 可选元素。

指定HTTP.sys跟踪的配置设置。
isapiFilters 可选元素。

指定 Web 服务器上的 ISAPI 筛选器的配置设置。
management 可选元素。

使用 IIS 管理器为远程管理配置 Web 服务器。
modules 可选元素。

指定 Web 服务器上的模块的配置设置。
odbcLogging 可选元素。

配置 Open Database Connectivity (ODBC) 日志记录。
security 可选元素。

指定包含安全相关节的节组。
serverRuntime 可选元素。

为 Web 服务器上的应用程序配置请求限制。
serverSideInclude 可选元素。

指定服务器端是否禁用 SSI) #exec 指令 (。
staticContent 可选元素。

配置静态文件请求处理程序设置。
tracing 可选元素。

配置请求跟踪设置。
urlCompression 可选元素。

配置静态和动态内容的压缩。
validation 可选元素。

配置 IIS 7 以检测设置为在 ISAPI 模式下运行的 ASP.NET 应用程序是否需要任何迁移才能在集成模式下正常运行。
webdav 可选元素。

配置 WebDAV 发布设置。
webSocket 可选元素。

通过 WebSocket 协议配置通信。

配置示例

以下配置示例定义一个简单的静态内容仅 <system.webServer> 元素。

<system.webServer>
   <asp />
   <caching enabled="true" enableKernelCache="true" />
   <cgi />
   <defaultDocument enabled="true">
      <files>
         <add value="Default.htm" />
         <add value="Index.htm" />
         <add value="Index.html" />
      </files>
   </defaultDocument>
   <directoryBrowse enabled="false" />
   <fastCgi />
   <globalModules>
      <add name="UriCacheModule" image="%windir%\System32\inetsrv\cachuri.dll" />
      <add name="FileCacheModule" image="%windir%\System32\inetsrv\cachfile.dll" />
      <add name="TokenCacheModule" image="%windir%\System32\inetsrv\cachtokn.dll" />
      <add name="HttpCacheModule" image="%windir%\System32\inetsrv\cachhttp.dll" />
      <add name="StaticCompressionModule" image="%windir%\System32\inetsrv\compstat.dll" />
      <add name="DefaultDocumentModule" image="%windir%\System32\inetsrv\defdoc.dll" />
      <add name="DirectoryListingModule" image="%windir%\System32\inetsrv\dirlist.dll" />
      <add name="ProtocolSupportModule" image="%windir%\System32\inetsrv\protsup.dll" />
      <add name="StaticFileModule" image="%windir%\System32\inetsrv\static.dll" />
      <add name="AnonymousAuthenticationModule" image="%windir%\System32\inetsrv\authanon.dll" />
      <add name="RequestFilteringModule" image="%windir%\System32\inetsrv\modrqflt.dll" />
      <add name="CustomErrorModule" image="%windir%\System32\inetsrv\custerr.dll" />
      <add name="HttpLoggingModule" image="%windir%\System32\inetsrv\loghttp.dll" />
      <add name="RequestMonitorModule" image="%windir%\System32\inetsrv\iisreqs.dll" />
   </globalModules>
   <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <staticTypes>
         <add mimeType="text/*" enabled="true" />
         <add mimeType="message/*" enabled="true" />
         <add mimeType="application/javascript" enabled="true" />
         <add mimeType="*/*" enabled="false" />
      </staticTypes>
   </httpCompression>
   <httpErrors>
      <error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="401.htm" />
      <error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="403.htm" />
      <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="404.htm" />
      <error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="405.htm" />
      <error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="406.htm" />
      <error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="412.htm" />
      <error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="500.htm" />
      <error statusCode="501" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="501.htm" />
      <error statusCode="502" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="502.htm" />
   </httpErrors>
   <httpLogging dontLog="false" />
   <httpProtocol />
   <httpRedirect />
   <httpTracing />
   <isapiFilters />
   <odbcLogging />
   <security>
      <access sslFlags="None" />
      <applicationDependencies />
      <authentication>
         <anonymousAuthentication enabled="true" userName="IUSR" />
         <basicAuthentication />
         <clientCertificateMappingAuthentication />
         <digestAuthentication />
         <iisClientCertificateMappingAuthentication />
         <windowsAuthentication />
      </authentication>
      <authorization />
      <ipSecurity />
      <isapiCgiRestriction notListedIsapisAllowed="false" notListedCgisAllowed="false">
         <clear />
      </isapiCgiRestriction>
      <requestFiltering>
         <fileExtensions allowUnlisted="true" applyToWebDAV="true" />
         <verbs allowUnlisted="true" applyToWebDAV="true" />
         <hiddenSegments applyToWebDAV="true">
            <add segment="Web.config" />
         </hiddenSegments>
      </requestFiltering>
   </security>
   <serverRuntime />
   <serverSideInclude />
   <staticContent lockAttributes="isDocFooterFileName">
      <mimeMap fileExtension=".png" mimeType="image/gif" />
      <mimeMap fileExtension=".htm" mimeType="text/html" />
      <mimeMap fileExtension=".html" mimeType="text/html" />
      <mimeMap fileExtension=".jpeg" mimeType="image/jpeg" />
      <mimeMap fileExtension=".png" mimeType="image/jpeg" />
      <mimeMap fileExtension=".js" mimeType="application/x-javascript" />
      <mimeMap fileExtension=".png" mimeType="image/png" />
      <mimeMap fileExtension=".txt" mimeType="text/plain" />
   </staticContent>
   <tracing>
      <traceFailedRequests />
      <traceProviderDefinitions />
   </tracing>
   <urlCompression />
   <validation />
   <webSocket />
</system.webServer>

代码示例

没有特定于元素的 <system.webServer> 代码示例。 有关配置元素中 <system.webServer> 发现的设置的代码示例,请参阅本主题 的配置详细信息 部分中列出的子元素。