Internet Information Services (IIS) 8 可讓開發人員輕鬆設定原生與受管理的程式碼模組,這些模組負責處理網頁伺服器發出的要求。為讓工作者處理序能夠將它們載入,必須正確設定模組。在正確的模組組態中,模組必須具有唯一名稱,以及一個有效類型或路徑。受管理模組可指定是否只有對 ASP.NET 應用程式或對受管理處理常式的要求應呼叫這些模組。指定之後,此設定便可將效能最佳化。
修正模組的前置條件
模組項目有選用的 preCondition 屬性,可包含所要載入模組的條件。例如,preCondition 可指定 IIS 僅針對在整合模式中執行的應用程式集區、在 ISAPI 模式中執行的應用程式集區或使用指定 NET Framwork 版本的應用程式集區載入模組。此最後一項設定可讓您針對使用不同版本的 CLR 執行階段的應用程式集區使用不同版本的受管理引擎模組。
以下範例取自具有 preCondition 屬性之模組項目的 ApplicationHost.config 檔案 globalModules 區段:
<globalModules>
<add name="ManagedEngine"
image="%Windir%\Microsoft.NET\Framework\v2.0.50727\webengine.dll"
preCondition="integratedMode,runtimeVersionv2.0,bitness32"
/>
</globalModules>
在載入各個模組之前,伺服器會先評估組態中目前存在的前置條件。如果有任一載入前置條件傳回 false,便不會載入該模組。
若要解決此問題:
備份 the ApplicationHost.config 檔案。 若要執行此操作,請參閱區段 A。
尋找並修正模組的 preCondition 屬性。確定其已正確設定,且符合將使用該模組之應用程式集區或工作者處理序的特性。若要尋找屬性,請參閱區段 B。
修正前置條件之後,應可成功載入模組。
備份 ApplicationHost.config 檔案
備份 ApplicationHost.config 檔案:
開啟提高權限的 [命令提示字元] 視窗。按一下 [開始],指向 [所有程式],按一下 [附屬應用程式],以滑鼠右鍵按一下 [命令提示字元],然後按一下 [以系統管理員身分執行]。
切換至目錄 %Windir%\system32\inetsrv。
輸入 appcmd add backup backupName 來備份 ApplicationHost.config 檔案。
系統將在 %Windir%\system32\inetsrv\backup 目錄底下使用您指定的備份名稱建立一個目錄。如果您不指定名稱,Appcmd.exe 會自動使用目前的日期和時間來產生目錄名稱。
在 ApplicationHost.config 檔案中尋找模組項目
在 ApplicationHost.config 檔案中尋找模組項目:
開啟提高權限的 [命令提示字元] 視窗。按一下 [開始],指向 [所有程式],按一下 [附屬應用程式],以滑鼠右鍵按一下 [命令提示字元],然後按一下 [以系統管理員身分執行]。
輸入 cd %Windir%\system32\inetsrv\config
輸入 notepad applicationHost.config
在記事本中,在 [system.webServer] 部分底下搜尋 [globalModules] 部分。
尋找包含 preCondition 屬性的模組項目,然後視需要修改。
儲存 ApplicationHost.config 檔案,然後結束記事本。
如需有關 globalModules 區段的詳細資訊,請參閱 IIS 8: 新增 globalModules 的元素 (IIS 設定結構描述) (英文)。
Target | Microsoft.Windows.InternetInformationServices.6.2.WebServer |
Category | Alert |
Enabled | True |
Event_ID | 2296 |
Event Source | Microsoft-Windows-IIS-W3SVC-WP |
Alert Generate | False |
Remotable | True |
Event Log | Application |
ID | Module Type | TypeId | RunAs |
---|---|---|---|
DS | DataSource | Microsoft.Windows.EventProvider | Default |
WA | WriteAction | Microsoft.Windows.Server.IIS.6.2.GenerateAlertAction.SuppressedByDescription | Default |
<Rule ID="Microsoft.Windows.InternetInformationServices.6.2.Module.has.an.invalid.precondition" Enabled="true" Target="Microsoft.Windows.InternetInformationServices.6.2.WebServer" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>Alert</Category>
<DataSources>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.EventProvider">
<ComputerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<LogName>Application</LogName>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Microsoft-Windows-IIS-W3SVC-WP</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>2296</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="WA" TypeID="Microsoft.Windows.Server.IIS.6.2.GenerateAlertAction.SuppressedByDescription">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.Windows.InternetInformationServices.6.2.Module.has.an.invalid.precondition.AlertMessage"]$</AlertMessageId>
</WriteAction>
</WriteActions>
</Rule>