<system.webServer>

概觀

元素 <system.webServer> 會指定 internet Information Services (IIS) 7 ApplicationHost.config檔案中許多月臺層級和應用層級組態設定的根項目,並包含定義 Web 服務器引擎和模組所用設定的組態元素。

注意

不同于 中找到 <system.applicationHost> 的設定,可以委派 專案中的 <system.webServer> 設定。

相容性

版本 備註
IIS 10.0 未在 IIS 10.0 中修改專案 <applicationInitialization>
IIS 8.5 未在 IIS 8.5 中修改專案 <system.webServer>
IIS 8.0 <applicationInitialization><webSocket> 元素已新增為子專案。
IIS 7.5 未在 IIS 7.5 中修改專案 <system.webServer>
IIS 7.0 元素 <system.webServer> 是在 IIS 7.0 中引進。
IIS 6.0 N/A

安裝程式

元素 <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 選擇性項目。

設定是否在網頁伺服器上啟用或停用瀏覽目錄,並指定要包含在目錄清單中的資訊。
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 選擇性項目。

指定網頁伺服器上的模組組態設定。
odbcLogging 選擇性項目。

設定 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> 所找到之設定的程式碼範例,請參閱本主題之組 態詳細 資料一節中所列的子項目。