我们在Visual Studio中将一些网站作为网站项目运行。 我们最近升级到了VS2015。现在我们无法将虚拟目录添加到新网站。
我们已经尝试右键单击"添加新的虚拟目标"我们收到错误消息以及在Project文件夹中编辑applicationhost.config。
这是VS2015的错误还是有办法创建目录?在升级到VS2015之前,已经在IIS Express上运行的项目没有问题。
PS:我知道线程here,但它没有帮助。
答案 0 :(得分:7)
FileSystem网站到IIS Express。
现在你可以毫无错误地创建它。
答案 1 :(得分:7)
上述两个答案都没有对我有用,我仍然不确定为什么会这样,但这就是我所做的:
修改驻留在项目中的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>
答案 2 :(得分:2)
如果您有解决方案文件&#34; .sln&#34;,则替代方案,然后按照以下步骤操作:
使用记事本打开解决方案文件。
找到以项目开头的行(&#34; {
例如:
项目(&#34; {E24C65DC-7377-472B-9ABA-BC803B73C61A}&#34;)=&#34; WebProject1&#34;,&#34; WebProject1&#34;,......
然后将其更改为:
项目(&#34; {E24C65DC-7377-472B-9ABA-BC803B73C61A}&#34;)=&#34; WebProject1&#34;,&#34; http://localhost:12345/WebProject1 &#34;,......
添加新属性
ProjectSection(WebsiteProperties) 中的SlnRelativePath =&#34; C:\ WebProject1 \&#34;
例如,来自
的ProjectSectionProject("{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
答案 3 :(得分:0)
类似于WhizBang的答案...
删除根项目文件夹中的文件(如果需要,请备份它)
.vs\config\applicationhost.config
在项目文件中清空IISUrl标签(如果存在)
<IISUrl></IISUrl>
转到项目属性,然后尝试再次创建您的虚拟URL。