如何设置 IIS Express 以在虚拟目录而不是根目录中运行 Visual Studio 项目?
我正在使用 VS 2010 和 IIS Express,而不是 Visual Studio 的 Web 服务器。
默认情况下,Web 应用程序在 localhost 的根目录下运行,如下所示: http://localhost:50369/
我希望它在 http://localhost:50369/Enet/< /code> 相反,因为这是发布时最终将到达的虚拟目录。
当我尝试添加虚拟目录时,我的 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>
当我浏览到 http://localhost:50369/
时,我的应用程序可以正常工作。 当我浏览到 http://localhost:50369/Enet/
时,我的 MVC 应用程序可以工作,但找不到 CSS 或 JS 文件等文件。它们的路径是我所期望的(与之前相同,除了前缀为 /Enet
),但没有找到它们。
正确执行此操作的步骤是什么?显然我在某个地方出错了。 非常感谢您的帮助。
I'm using VS 2010 and a using IIS Express instead of the Visual Studio's web server.
By default the Web application runs at the root of localhost something like this: 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.
When I tried to add the virtual directory my applicationhost.config looked this this:
<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.
When I browse to http://localhost:50369/Enet/
my MVC application works, but it can't find files like CSS or JS files. The paths for them are what I'd expect (the same as before except prefixed with /Enet
) but they're not found.
What are the steps to do this correctly? Obviously I've gone wrong somewhere.
Thanks very much for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明我的配置几乎是正确的,但应用程序需要不同的物理路径。
看来您确实需要根目录下的第一个应用程序,即使您不使用它。我只是将其物理路径设置为 /ENet 以外的路径,并且它起作用了。
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. I just set its physical path to be something other than that of /ENet's and it worked.