我正在使用Visual Studion 2013
和MVC4
。我在RegisterArea
每个区域的应用程序和路由规则(替代)中使用区域。
我的公司决定将我们的Web应用程序实时上移,现在我必须将其附加Calculator
到所有javascript脚本,css和应用程序中的所有其他路径上+对所有这些都执行此操作Controllers
我说的是来自
http://host:1234/legal-services/Wills/Index
至 http://host:1234/legal-services/Calculator/Wills/Index
因此,在替换了所有脚本之后,我去了csproj
并为应用程序根目录添加了覆盖,因此它将对所有控制器进行覆盖,但这被完全忽略了。
我假设覆盖主机时只能使用主机名和端口,而不能使用文件夹。
更新:我也尝试过直接修改.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冲突的应用程序?
因此解决方案是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>
希望这可以节省您一些时间。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句