您的位置:首页 > 其它

关于IIS虚拟目录继承根Web.Config的问题解决办法

2012-05-24 14:43 579 查看
利用配置文件的配置节可以让它不继承父目录的配置文件,如下

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

把它加在父目录的<system.web>节外面即可,测试一下果然如此,甚喜,虽记之以备忘,同时也于大伙共享!

下面是更好的一个:

虚拟目录中的web.config继承了主目录中的web.config出现问题是由于根目录中的web.config添加了httphandler、 httpmodule 引起的。

解决办法:将 httphandler httpmodule的声明添加到location中。

如下所示:

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

<system.web>

<httpModules>

<add name="UrlRewriteModule"

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

</httpModules>

</system.web>

</location>

path 不用说指定的是一个目录

allowOverride 指是否可以将这个重写

inheritInChildApplications 指是否被子级应用程序继承

附:解决使用URLRewriter,真实html页面无法访问的问题

1、

一般我们使用 URLRewriter 来映射后缀 .aspx 成 .html 的形式 ,但是原来真实存在的后缀为.html的页面则无法访问到(因为它也被定义的规则映射到其他页面了),解决办法其实很简单,原来的.html页面的后缀改成.htm就可以,或者映射后缀 .aspx成 .htm 的形式也可以,只要.html 与 .htm 有一个为 aspnet_isapi.dll 来解析即可,再说我们在Visual Studio 开发环境中创建静态页面的时候,默认的后缀就是.htm,无意中就和我们要映射的 .html
区分开了,如果你选择的是URLRewriter组件来做url映射,又定要映射为 .html ,那么上面所说就是唯一的解决办法啦!
2、

<compilation debug="true">

<buildProviders>

<add extension=".htm" type="System.Web.Compilation.PageBuildProvider"/>

</buildProviders>

</compilation>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: