如何使用Visual Studio 2015为网站项目配置其他虚拟目录 [英] How to configure a different virtual directory for web site project with Visual Studio 2015

查看:196
本文介绍了如何使用Visual Studio 2015为网站项目配置其他虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在VS 2012中开发的c#网站类型项目.我想使用VS 2015,并且在指定不同于默认根目录/的虚拟目录时遇到麻烦.

I have a c# Web Site type project which was developed in VS 2012. I want to use VS 2015 and I have trouble specifying a different virtual directory than the default root which is /.

在vs 2012中,sln文件中包含以下几行:

In vs 2012, in the sln file there are these lines:

VWDPort = "59903"
VWDDynamicPort = "true"
VWDVirtualPath = "/myapp"

一切正常,即,应用程序在浏览器中启动时,它会转到: http://localhost:59903/myapp .

and everything works as expected, i.e. when the app launches in the browser it goes to: http://localhost:59903/myapp.

我在VS 2015中打开了该解决方案,并且vs创建了一个隐藏的.vs文件夹,它将applicanthost.config文件放在.vs \ config文件夹下.

I opened the solution in VS 2015 and vs creates a hidden .vs folder where it puts the applicantionhost.config file under the .vs\config folder.

这是它为网站项目创建的条目:

This is the entry it creates for the Web Site project:

<site name="My Web Application" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\costa\Documents\webapps\My Web Application" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:59903:localhost" />
    </bindings>
</site>

我尝试使用应用程序和virtualDirectory元素的路径设置,但无济于事.

I tried to play with the path settings of the application and virtualDirectory elements but nothing works.

如果设置了application元素的路径,则不会加载网站项目.如果我按原样保留它,并设置virtualDirectory的路径,例如说/myapp,我将收到HTTP错误500.0-内部服务器错误,模块:AspNetAppInitializationFailureModule,处理程序:PageHandlerFactory-Integrated-4.0或ExtensionlessUrlHandler-Integrated-4.0,具体取决于我的网址尝试访问.

If I set the path for the application element, the web site project doesn't load. If I leave it as is and set the path of virtualDirectory to let's say /myapp I get HTTP Error 500.0 - Internal Server Error, Module: AspNetAppInitializationFailureModule, Handler: PageHandlerFactory-Integrated-4.0 or ExtensionlessUrlHandler-Integrated-4.0 depending on the url that I try to access.

如果我将路径设置为"/",则一切正常.

If I set the paths to just "/" everything works fine.

让我感到困惑的是,当我在解决方案资源管理器中选择网站"项目时,在属性窗口中禁用了SSL URL和URL属性.我不知道从哪儿来的.我以为URL可能来自applicationhost.config文件.

What puzzles me is that, when I select the Web Site project in the solution explorer, in the properties window the SSL URL and URL properties are disabled. I don't know where it's getting them from. I thought the URL comes perhaps come from the applicationhost.config file.

在网站属性页面窗口中的开始选项"下,我有开始操作" =使用当前页面",服务器" =使用默认Web服务器".

In the web site property pages window, under Start Options, I have Start Action = Use current page, Server = Use default Web Server.

我正在Windows 2008 R2 SP1 VM上使用VS2015和Update 3(不要问我为什么会这样).

I am using VS2015 with Update 3 on a windows 2008 R2 SP1 VM (don't ask me why it's like this).

有什么想法吗?

我做了一些研究,但找不到任何东西.另一个晦涩的事情(imo)是通过选择以下选项在IIS express中创建站点或虚拟目录的能力:新网站->浏览->选择左侧的本地IIS.我不太确定这与现有的网站项目有什么关系.

I did do some research but I couldn't find anything. One other obscure thing (imo) is the ability to create sites or virtual directories in IIS express by choosing: New Web Site -> Browse -> select Local IIS on the left side. I am not too sure what this has to do with an existing web site project.

谢谢

推荐答案

具有以下配置使其可以运行,即 http: //localhost:59903/myapp http://localhost:59903 一样可以正常工作.. >

Having the following configuration made it work, i.e. http://localhost:59903/myapp works now as well as http://localhost:59903.

<site name="My Web Application" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\costa\Documents\webapps\My Web Application" />
    </application>
    <application path="/myapp" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\costa\Documents\webapps\My Web Application" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:59903:localhost" />
    </bindings>
</site>

请注意存在两个应用程序元素.

Note the presence of two application elements.

也请参见: IIS7:无法识别的配置"的可能原因路径错误

这篇关于如何使用Visual Studio 2015为网站项目配置其他虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆