虚拟目录和UrlRewriter不兼容的解决办法

我碰到过,像如果website部署了一个网站,然后想再加入个virtual direcotry部署另外一个网站。
这时候website的web.config会影响VirtualDirectory的网站。

lz可以试一试5楼的链接的文章,我贴到下面,如果成功的话,吱一声。


在我们的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>

这样配置后就不会影响到我们的子集应用程序了,即虚拟目录等
原文地址:https://www.cnblogs.com/dodui/p/2234153.html