简体   繁体   English

如何设置IIS Express以在虚拟目录而不是root中运行Visual Studio项目?

[英]How to setup IIS Express to run a Visual Studio project in a Virtual Directory instead of root?

I'm using VS 2010 and a using IIS Express instead of the Visual Studio's web server. 我正在使用VS 2010并使用IIS Express而不是Visual Studio的Web服务器。

By default the Web application runs at the root of localhost something like this: http://localhost:50369/ 默认情况下,Web应用程序在localhost的根目录下运行,如下所示: http://localhost:50369/

I wish it to run at http://localhost:50369/Enet/ instead as this is the virtual directory it will end up at when published. 我希望它在http://localhost:50369/Enet/上运行,因为这是它在发布时最终的虚拟目录。

When I tried to add the virtual directory my applicationhost.config looked this this: 当我尝试添加虚拟目录时,我的applicationhost.config看起来像这样:

<site name="EssenceNet" id="1">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="E:\dev\EssenceNet\Src\EssenceNet.Web" />
                </application>
                <application path="/ENet">
                    <virtualDirectory path="/" physicalPath="E:\dev\EssenceNet\Src\EssenceNet.Web" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation=":50369:localhost" />
                </bindings>
            </site>

When I browse to http://localhost:50369/ my application works. 当我浏览到http://localhost:50369/我的应用程序工作。 When I browse to http://localhost:50369/Enet/ my MVC application works, but it can't find files like CSS or JS files. 当我浏览http://localhost:50369/Enet/我的MVC应用程序工作,但它找不到像CSS或JS文件的文件。 The paths for them are what I'd expect (the same as before except prefixed with /Enet ) but they're not found. 它们的路径是我所期望的(与之前相同,除了前缀为/Enet )但是找不到它们。

What are the steps to do this correctly? 正确执行此操作的步骤是什么? Obviously I've gone wrong somewhere. 显然我在某个地方出了问题。 Thanks very much for any help. 非常感谢您的帮助。

It turns out my config is almost correct but that the applications need to be different physical paths. 事实证明我的配置几乎是正确的,但应用程序需要是不同的物理路径。

It seems you do need that 1st application at root even if you don't use it. 即使您不使用它,您似乎也需要在root用户使用第一个应用程序。 I just set its physical path to be something other than that of /ENet's and it worked. 我只是将它的物理路径设置为除了/ ENet之外的其他东西并且它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM