【发布时间】:2012-06-27 09:18:42
【问题描述】:
在我的解决方案中,我有 2 个项目,分别称为 Foo 和 Bar。部署后,Foo 是根站点 (http://mycompany.com),Bar 是子目录 (http://mycompany.com/sub)。
当我在本地机器上的 IIS Express 中本地处理它们时,我需要将内容复制到两个项目的 web.config 中,因为我分别处理它们。例如,我的重写规则中有一个用于“缓存破坏”的 HMTL5 样板规则:
<rewrite>
<rules>
<rule name="Cachebusting">
<match url="^(.+)\.\d+(\.(js|css|png|jpg|gif)$)" />
<action type="Rewrite" url="{R:1}{R:2}" />
</rule>
</rules>
</rewrite>
如果我只是将它留在 Foo 的 web.config 中,那么当我在 Bar 上工作时,它不会被应用并且我会收到错误,因为重写没有发生。因此,我已将两个项目的部分复制到 web.config 中。
但是当我将解决方案发布到 Azure 时,由于 Foo 的 web.config 位于根目录中,因此由于继承规则而发生冲突。
管理此问题的最佳方法是什么?我尝试搜索该主题,但找不到所描述的确切问题。
更新:
我的 IIS Express 的 applicationhost.config 是这样的:
<site name="Bar" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:65052:localhost" />
</bindings>
</site>
<site name="Foo" id="4">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50477:localhost" />
</bindings>
</site>
我尝试对其进行编辑以使这两个应用程序成为同一个站点的一部分,进行了这些更改,但没有运气。似乎已经破坏了一切:)
<site name="Foo" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
</application>
<application path="/Sub" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:65052:localhost" />
</bindings>
</site>
【问题讨论】:
-
两个站点不能共享同一个链接配置文件吗?
-
他们不能共享同一个 web.config 文件,因为子站点中的设置不适用于父站点(如连接字符串)
标签: asp.net visual-studio-2010 web-config