通过 Internet Information Services (IIS) 8,开发人员可轻松配置本机和托管的代码模块,这些模块用于处理向 Web 服务器发出的请求。为使工作进程可以加载模块,必须正确配置这些模块。正确的模块配置要求模块具有唯一名称和有效类型或路径。被管理的模块可以指定是否仅为对 ASP.NET 应用程序或被管理处理程序的请求调用它们。在指定对象之后,此设置可优化性能。
定义全局模块
为使 IIS 成功处理请求,必须至少在 ApplicationHost.config 文件的 globalModules 部分定义一个全局模块。模块定义必须包含模块的唯一名称属性以及可指定 .dll 文件(包含全局模块)的文件系统路径的图像属性。
将全局模块定义添加到 ApplicationHost.config
若要通过记事本将全局模块定义添加到 ApplicationHost.config,请执行以下操作:
打开提升的命令提示符窗口。单击“开始”,指向“所有程序”,再单击“附件”,右键单击“命令提示符”,然后单击“以管理员身份运行”。
键入 cd %Windir%\system32\inetsrv\config
键入 notepad applicationHost.config
在记事本中,搜索“system.webServer”部分下的“globalModules”部分。
添加包含名称和图像属性的模块入口。以下部分显示了一个示例。
保存 ApplicationHost.config 文件并退出记事本。
全局模块定义示例
<globalModules>
<add name="AccessCheckModule"
image="D:\Windows\system32\inetsrv\checkacc.dll"
preCondition=""
/>
</globalModules>
要详细了解 globalModules 部分,请参阅 IIS 8: 为 globalModules 添加元素(IIS 设置架构)。
Target | Microsoft.Windows.InternetInformationServices.6.2.WebServer |
Category | Alert |
Enabled | True |
Event_ID | 2298 |
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.The.Global.Modules.list.is.empty" 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>2298</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.The.Global.Modules.list.is.empty.AlertMessage"]$</AlertMessageId>
</WriteAction>
</WriteActions>
</Rule>