ApplicationHost.config(IIS存储配置区文件)

知识养成了思想,思想同时又在融化知识。这篇文章主要讲述ApplicationHost.config(IIS存储配置区文件)相关的知识,希望能为你提供帮助。
对于一个刚刚创建网站,以ASP.NET MVC5为例。
我们并没有在网页的配置文件(web.config)中配置一些处理程序或模块,如处理Session的SessionStateModule模块,映射Url的UrlRoutingModule模块等。
但是我们依然可以在控制器中正常的访问Session。我们请求的url依然能正确的映射到控制器和Action。
 
【ApplicationHost.config(IIS存储配置区文件)】这是因为在IIS的配置文件中ApplicationHost.config的modules  元素中注册了很多模块 ,这些模块供IIS承载的所有应用程序使用。
在 ApplicationHost.config 文件中注册的模块具有全局范围,因为它们为所有由 IIS 承载的 Web 应用程序而注册。
同样,在 ApplicationHost.config 文件的  globalModules  元素中定义的本机代码模块也具有全局范围。如果 Web 应用程序不需要全局模块,则可以将其禁用。
 
当然这也只是这个配置文件的功能的一小部分,有时我们在IIS管理器中添加的映射关系等也都会存储在这个配置文件中。
但是没有十足的把握,不要修改这个配置文件或在修改前进行备份。因为这个文件供整个IIS承载的所有应用程序使用。一些不起眼的配置节点的丢失,对某些程序可能就是致命的。
 
下面我们列出这个配置文件的部分内容,大家也可以再自己的电脑C盘中搜索这个文件,详细的查看其中的内容。

ApplicationHost.config(IIS存储配置区文件)

文章图片
ApplicationHost.config(IIS存储配置区文件)

文章图片
1< !-- 2 3The < globalModules> section defines all native-code modules. 4To enable a module, specify it in the < modules> section. 5 6--> 7< globalModules> 8< add name="UriCacheModule" image="%IIS_BIN%\\cachuri.dll" /> 9 < !--< add name="FileCacheModule" image="%IIS_BIN%\\cachfile.dll" /> --> 10< add name="TokenCacheModule" image="%IIS_BIN%\\cachtokn.dll" /> 11 < !--< add name="HttpCacheModule" image="%IIS_BIN%\\cachhttp.dll" /> --> 12< add name="DynamicCompressionModule" image="%IIS_BIN%\\compdyn.dll" /> 13< add name="StaticCompressionModule" image="%IIS_BIN%\\compstat.dll" /> 14< add name="DefaultDocumentModule" image="%IIS_BIN%\\defdoc.dll" /> 15< add name="DirectoryListingModule" image="%IIS_BIN%\\dirlist.dll" /> 16< add name="ProtocolSupportModule" image="%IIS_BIN%\\protsup.dll" /> 17< add name="HttpRedirectionModule" image="%IIS_BIN%\\redirect.dll" /> 18< add name="ServerSideIncludeModule" image="%IIS_BIN%\\iis_ssi.dll" /> 19< add name="StaticFileModule" image="%IIS_BIN%\\static.dll" /> 20< add name="AnonymousAuthenticationModule" image="%IIS_BIN%\\authanon.dll" /> 21< add name="CertificateMappingAuthenticationModule" image="%IIS_BIN%\\authcert.dll" /> 22< add name="UrlAuthorizationModule" image="%IIS_BIN%\\urlauthz.dll" /> 23< add name="BasicAuthenticationModule" image="%IIS_BIN%\\authbas.dll" /> 24< add name="WindowsAuthenticationModule" image="%IIS_BIN%\\authsspi.dll" /> 25 < !--< add name="DigestAuthenticationModule" image="%IIS_BIN%\\authmd5.dll" /> --> 26< add name="IISCertificateMappingAuthenticationModule" image="%IIS_BIN%\\authmap.dll" /> 27< add name="IpRestrictionModule" image="%IIS_BIN%\\iprestr.dll" /> 28< add name="DynamicIpRestrictionModule" image="%IIS_BIN%\\diprestr.dll" /> 29< add name="RequestFilteringModule" image="%IIS_BIN%\\modrqflt.dll" /> 30< add name="CustomLoggingModule" image="%IIS_BIN%\\logcust.dll" /> 31< add name="CustomErrorModule" image="%IIS_BIN%\\custerr.dll" /> 32< add name="HttpLoggingModule" image="%IIS_BIN%\\loghttp.dll" /> 33 < !--< add name="TracingModule" image="%IIS_BIN%\\iisetw.dll" /> --> 34< add name="FailedRequestsTracingModule" image="%IIS_BIN%\\iisfreb.dll" /> 35< add name="RequestMonitorModule" image="%IIS_BIN%\\iisreqs.dll" /> 36< add name="IsapiModule" image="%IIS_BIN%\\isapi.dll" /> 37< add name="IsapiFilterModule" image="%IIS_BIN%\\filter.dll" /> 38< add name="CgiModule" image="%IIS_BIN%\\cgi.dll" /> 39< add name="FastCgiModule" image="%IIS_BIN%\\iisfcgi.dll" /> 40 < !--< add name="WebDAVModule" image="%IIS_BIN%\\webdav.dll" /> --> 41< add name="RewriteModule" image="%IIS_BIN%\\rewrite.dll" /> 42< add name="ConfigurationValidationModule" image="%IIS_BIN%\\validcfg.dll" /> 43< add name="ApplicationInitializationModule" image="%IIS_BIN%\\warmup.dll" /> 44< add name="WebSocketModule" image="%IIS_BIN%\\iiswsock.dll" /> 45< add name="WebMatrixSupportModule" image="%IIS_BIN%\\webmatrixsup.dll" /> 46< add name="ManagedEngine" image="%windir%\\Microsoft.NET\\Framework\\v2.0.50727\\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness32" /> 47< add name="ManagedEngine64" image="%windir%\\Microsoft.NET\\Framework64\\v2.0.50727\\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness64" /> 48< add name="ManagedEngineV4.0_32bit" image="%windir%\\Microsoft.NET\\Framework\\v4.0.30319\\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness32" /> 49< add name="ManagedEngineV4.0_64bit" image="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness64" /> 50< /globalModules>

globalModules上面的配置节点中列出的都是本机代码模块(native-code)。大家如果要添加自己的托管代码模块(managed-code),就添加早modules中。
然后通过环境变量去读取这些文件。他们是整个iis的基石。
ApplicationHost.config(IIS存储配置区文件)

文章图片
ApplicationHost.config(IIS存储配置区文件)

文章图片
< modules> < !-- < add name="HttpCacheModule" lockItem="true" /> --> < add name="DynamicCompressionModule" lockItem="true" /> < add name="StaticCompressionModule" lockItem="true" /> < add name="DefaultDocumentModule" lockItem="true" /> < add name="DirectoryListingModule" lockItem="true" /> < add name="IsapiFilterModule" lockItem="true" /> < add name="ProtocolSupportModule" lockItem="true" /> < add name="HttpRedirectionModule" lockItem="true" /> < add name="ServerSideIncludeModule" lockItem="true" /> < add name="StaticFileModule" lockItem="true" /> < add name="AnonymousAuthenticationModule" lockItem="true" /> < add name="CertificateMappingAuthenticationModule" lockItem="true" /> < add name="UrlAuthorizationModule" lockItem="true" /> < add name="BasicAuthenticationModule" lockItem="true" /> < add name="WindowsAuthenticationModule" lockItem="true" /> < !-- < add name="DigestAuthenticationModule" lockItem="true" /> --> < add name="IISCertificateMappingAuthenticationModule" lockItem="true" /> < add name="WebMatrixSupportModule" lockItem="true" /> < add name="IpRestrictionModule" lockItem="true" /> < add name="DynamicIpRestrictionModule" lockItem="true" /> < add name="RequestFilteringModule" lockItem="true" /> < add name="CustomLoggingModule" lockItem="true" /> < add name="CustomErrorModule" lockItem="true" /> < add name="IsapiModule" lockItem="true" /> < add name="HttpLoggingModule" lockItem="true" /> < add name="FailedRequestsTracingModule" lockItem="true" /> < add name="CgiModule" lockItem="true" /> < add name="FastCgiModule" lockItem="true" /> < !--< add name="WebDAVModule" /> --> < add name="RewriteModule" /> < add name="OutputCache" type="System.Web.Caching.OutputCacheModule" preCondition="managedHandler" /> < add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="managedHandler" /> < add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" preCondition="managedHandler" /> < add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="managedHandler" /> < add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition="managedHandler" /> < add name="RoleManager" type="System.Web.Security.RoleManagerModule" preCondition="managedHandler" /> < add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" preCondition="managedHandler" /> < add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" preCondition="managedHandler" /> < add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" preCondition="managedHandler" /> < add name="Profile" type="System.Web.Profile.ProfileModule" preCondition="managedHandler" /> < add name="UrlMappingsModule" type="System.Web.UrlMappingsModule" preCondition="managedHandler" /> < add name="ApplicationInitializationModule" lockItem="true" /> < add name="WebSocketModule" lockItem="true" /> < add name="ServiceModel-4.0" type="System.ServiceModel.Activation.ServiceHttpModule,System.ServiceModel.Activation,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ConfigurationValidationModule" lockItem="true" /> < add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv2.0" /> < /modules>

Modules 
ApplicationHost.config(IIS存储配置区文件)

文章图片

 
 
ApplicationHost.config(IIS存储配置区文件)

文章图片
ApplicationHost.config(IIS存储配置区文件)

文章图片
1 < handlers accessPolicy="Read, Script"> 2< !--< add name="WebDAV" path="*" verb="PROPFIND,PROPPATCH,MKCOL,PUT,COPY,DELETE,MOVE,LOCK,UNLOCK" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" /> --> 3< add name="AXD-ISAPI-4.0_64bit" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 4< add name="PageHandlerFactory-ISAPI-4.0_64bit" path="*.aspx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 5< add name="SimpleHandlerFactory-ISAPI-4.0_64bit" path="*.ashx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 6< add name="WebServiceHandlerFactory-ISAPI-4.0_64bit" path="*.asmx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 7< add name="HttpRemotingHandlerFactory-rem-ISAPI-4.0_64bit" path="*.rem" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 8< add name="HttpRemotingHandlerFactory-soap-ISAPI-4.0_64bit" path="*.soap" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 9< add name="svc-ISAPI-4.0_64bit" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" /> 10< add name="rules-ISAPI-4.0_64bit" path="*.rules" verb="*" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" /> 11< add name="xoml-ISAPI-4.0_64bit" path="*.xoml" verb="*" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" /> 12< add name="xamlx-ISAPI-4.0_64bit" path="*.xamlx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" /> 13< add name="aspq-ISAPI-4.0_64bit" path="*.aspq" verb="*" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 14< add name="cshtm-ISAPI-4.0_64bit" path="*.cshtm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 15< add name="cshtml-ISAPI-4.0_64bit" path="*.cshtml" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 16< add name="vbhtm-ISAPI-4.0_64bit" path="*.vbhtm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 17< add name="vbhtml-ISAPI-4.0_64bit" path="*.vbhtml" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 18< add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" /> 19< add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="

    推荐阅读