Root和虚拟目录中Web.Config问题的解决方案[操作篇]

Root和虚拟目录中Web.Config问题的解决方案[操作篇]

很多人有时都会为虚拟目录中的web.config继承了主目录中的web.config而苦恼, 大部分主要是由于根目录中的web.config添加了httphandler、 httpmodule 引起的。 其实这个问题解决起来很简单,只将 httphandler httpmodule的声明添加到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>

path 不用说指定的是一个目录
allowOverride 指是否可以将这个重写
inheritInChildApplications 指是否被子级应用程序继承

我遇到的问题是主目录中引用了DevExpress控件,结果在WebService中调用任何页面,都提示:
未能加载文件或程序集“DevExpress.Web.ASPxGridView.v8.1, Version=8.1.1.0, Culture=neutral, PublicKeyToken=e0b364db0ebed33f”或它的某一个依赖项。系统找不到指定的文件。 (的确有效,感谢原创作者。)

 

 

 

 

=======================[以上为转载,以下为原创]===============================

 

具体操作,分三步走:

第一步:打开根目录下的Web.Config

第二步:找到第一个  <system.web>,在之前插入“ <location path="." allowOverride="true" inheritInChildApplications="false">

 <!--配置 ASP.NET Web 应用程序和控制应用程序行为的配置元素。-->

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

  <system.web>

......
   <!--配置 ASP.NET 使用的安全身份验证模式,以标识传入的用户。-->
   <authentication mode="Forms">
    <forms loginUrl="~/User/Login.aspx" name=".ASPXAUTH" defaultUrl="User/Default.aspx" timeout="30" path="/" />
   </authentication>
   <!--配置 Web 应用程序的授权,以控制客户端对 URL 资源的访问。-->
   <authorization>
    <allow users="*" />
    <deny users="?" />
   </authorization>
......

</system.web>
 </location>
第三步:找到第一个  </system.web>,在之后插入“ </location>”,保存后再看效果。

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值