我们在Visual Studio中将一些站点作为Web站点项目运行。我们最近升级到了VS2015。现在我们无法将虚拟目录添加到新网站。
我们已经尝试右键单击“添加新虚拟目录”,我们在其中收到错误消息以及编辑Project文件夹中的applicationhost.config。
这是VS2015的错误还是有办法创建目录?在升级到VS2015之前,已经在IIS Express上运行的项目没有问题。
PS:我知道线程here但它没有帮助。
FileSystem网站到IIS Express。
现在您可以毫无错误地创建它。
上面的答案都没有对我有用,我仍然不确定为什么会这样,但这就是我所做的:
修改驻留在项目中的Applicationhost.config文件:
最初它看起来像这样:
<site name="Website" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\MyWebsite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51005:localhost" />
</bindings>
</site>
我不得不添加另一个应用程序路径条目:
<application path="/mywebsite" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\MyWebsite" />
</application>
所以最终看起来像这样:
<site name="Website" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\MyWebsite" />
</application>
<application path="/mywebsite" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\MyWebsite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51005:localhost" />
</bindings>
</site>
如果你有解决方案文件“.sln”,请选择,然后按照以下步骤操作:
例如:
项目(“{E24C65DC-7377-472B-9ABA-BC803B73C61A}”)=“WebProject1”,“WebProject1”,......
然后将其更改为:
项目(“{E24C65DC-7377-472B-9ABA-BC803B73C61A}”)=“WebProject1”,“http://localhost:12345/WebProject1”,......
并添加新的属性
SlnRelativePath =“C:\ WebProject1 \”
在ProjectSection(WebsiteProperties)中
例如,ProjectSection来自
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebProject1", "WebProject1", "{6D411253-734E-401A-A049-9620FC55D4FB}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
Debug.AspNetCompiler.VirtualPath = "/WebProject1"
Debug.AspNetCompiler.PhysicalPath = "C:\WebProject1\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebProject1\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/WebProject1"
Release.AspNetCompiler.PhysicalPath = "C:\WebProject1\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebProject1\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
终于成为了这个:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebProject1", "http://localhost:12345/WebProject1", "{6D411253-734E-401A-A049-9620FC55D4FB}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
Debug.AspNetCompiler.VirtualPath = "/WebProject1"
Debug.AspNetCompiler.PhysicalPath = "C:\WebProject1\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebProject1\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/WebProject1"
Release.AspNetCompiler.PhysicalPath = "C:\WebProject1\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebProject1\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "C:\WebProject1\"
EndProjectSection
EndProject
与WhizBang的回答类似......
删除根项目文件夹中的文件(如果您愿意,请备份)
.vs\config\applicationhost.config
清空项目文件中的IISUrl标记(如果存在)
<IISUrl></IISUrl>
转到项目属性并尝试再次创建虚拟URL。