【问题标题】:Adding multiple levels of virtual directory to application root in VS2013 MVC4 IIS express在VS2013 MVC4 IIS express中向应用程序根目录添加多级虚拟目录
【发布时间】:2016-05-03 14:05:39
【问题描述】:

我正在使用Visual Studion 2013MVC4。我在每个区域的应用程序和路由规则(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>

但这对以太没有影响。

更新 2:

所以在C:\Users\[username]\Documents\IISExpress\configapplicationHost.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.

&lt;authentication mode="Forms"&gt;

表示该路径未识别为web应用或存在web.config冲突。

如何配置它以便 path="/legal-services/calculator" 被识别为没有 web.config 冲突的应用程序?

【问题讨论】:

    标签: visual-studio-2013 web-config .net-4.5 iis-express virtual-directory


    【解决方案1】:

    因此解决方案是在 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>
    

    希望这可以为您节省一些时间。

    【讨论】:

    • Jexus Manager 可能是此类管理网络的更简单解决方案,jexusmanager.com
    猜你喜欢
    • 2018-02-26
    • 2011-06-11
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多