[ASP.NET]在二级目录中禁止web.config继承IIS根目录的web.config的配置

广告:

环境:asp.net mvc2.0 asp.net 3.5 sp1

在我们的ASPNET二级目录应用中,有时会出现一些异常,比如在根目录的web.config中添加了HttpHandler以及HttpModule(如一些UrlRewiter重写组件、自己的全局HttpModule等)在二级目录运行时就会提示找不到找不到指定的文件的异常。

解决方法是在根目录的web.config中针对根路径通过location配置这些module和handler等, 并且在location设置允许子目录重写,以及是否被子集应用程序继承设置为false,如下把<system.web> </system.web>包含在<location></location>结点内部:

<configuration>

<location path="." allowOverride="true" inheritInChildApplications="false">

<system.web>

<httpModules>

<add name="UrlRewriteModule"

type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />

</httpModules>

</system.web>

</location>

</configuration>

这样配置后就不会影响到我们的子集应用程序了,即二级目录等

广告:

编辑:Admin 时间:2013/10/15 9:04:52 阅览:2571   返回    
web.config
二级目录
扫描关注53BK报刊官网
扫描关注阅速公司微信