我正在使用Visual Studion 2013
和MVC4
。我在每个区域使用应用程序和路由规则(RegisterArea
覆盖)中的区域。
我的公司决定将我们的网络应用程序升级到现场,现在我必须将Calculator
附加到所有javascript脚本,css和跨应用程序的所有其他路径+为所有Controllers
执行此操作
我所说的是来自
http://host:1234/legal-services/Wills/Index
到http://host:1234/legal-services/Calculator/Wills/Index
所以在替换了所有脚本之后我转到csproj
并为应用程序root添加了覆盖,因此它会覆盖所有控制器,但这完全被忽略了。
我假设当覆盖主机时只能使用主机名和端口但不能使用文件夹。
更新
我还尝试直接修改.csproj
文件以更改IISUrl
设置
这
<IISUrl>http://localhost:50766/legal-services/</IISUrl>
到
<IISUrl>http://localhost:50766/legal-services/Calculator/</IISUrl>
但这对以太没有影响。
UPDATE2:
因此applicationHost.config
中的C:\Users\[username]\Documents\IISExpress\config
中的配置发生了更改,以添加其他虚拟目录
来自
<virtualDirectory path="/" physicalPath="C:\hg\Website" />
<virtualDirectory path="/legal-services" physicalPath="C:\hg\Website" />
到
<virtualDirectory path="/" physicalPath="C:\hg\Website" />
<virtualDirectory path="/legal-services/calculator" physicalPath="C:\hg\Website" />
然而现在我遇到了不同的问题,因为我现在正在处理虚拟目录上的多个层,我得到403并且它非常有意义,因为中间的路径(/legal-services
)不在列表中。
当我添加
<virtualDirectory path="/" physicalPath="C:\hg\Website" />
<virtualDirectory path="/legal-services/calculator" physicalPath="C:\hg\Website" />
<virtualDirectory path="/legal-services" physicalPath="C:\hg\Website" />
我遇到配置错误(我假设因为所有3条路径都指向同一目录)
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
<authentication mode="Forms">
表示路径未标识为Web应用程序或存在web.config冲突。
如何配置这个以便将path =“/ legal-services / calculator”标识为没有web.config冲突的应用程序?
答案 0 :(得分:0)
所以解决方案是在applicationHost.config
中创建两个单独的应用程序路径,如下所示,其中主路径具有虚拟目录路径的一部分,第二个应用程序具有完整的虚拟目录路径,如下所示:
<site name="Website-Site" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\hg\Website" />
<virtualDirectory path="/legal-services" physicalPath="C:\hg\" />
</application>
<application path="/legal-services/Calculator" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\hg\Website" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50766:localhost" />
</bindings>
</site>
希望这可以节省你一些时间。