VS 2012无法加载与自定义绑定主机使用IIS的项目 – 认为它使用IIS Express

我有一个使用IIS的ASP.NET项目。 IIS站点被configuration为使用自定义绑定主机名。 项目文件包含以下设置:

... <UseIISExpress>false</UseIISExpress> ... <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <WebProjectProperties> <UseIIS>True</UseIIS> <AutoAssignPort>False</AutoAssignPort> <DevelopmentServerPort>8662</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl>http://custom.host.name/</IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl></CustomServerUrl> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> </WebProjectProperties> </FlavorProperties> </VisualStudio> </ProjectExtensions> ... 

当以这种方式configuration项目时,我可以从http://custom.host.name/访问该站点,并且在debugging时VS自动附加到IIS工作进程。

当我重新加载项目(通过closures/重新打开解决scheme或通过在项目上下文菜单中卸载/重新加载),意外的事情发生。 在解决scheme资源pipe理器中项目名称右侧显示项目失败加载(load failed) ,消息框显示以下消息(它也显示在输出窗口中):

 The URL 'http://custom.host.name/' for Web project 'Some.Asp.Net.Project' is configured to use IIS Express as the web server but the URL is currently configured on the local IIS web server. To open this project, you must use IIS Manager to remove the bindings using this URL from the local IIS web server. 

我已经尝试从IIS Express applicationhost.config文件中删除项目站点configuration,但它没有帮助。

将项目映射到默认站点下的IIS应用程序时,我不会遇到此问题。

VS版本是终极2012更新3。

作为pipe理员打开并没有解决我的问题。 对我来说固定的是打开.csprojcsproj.user文件,并确保两个都有UseIISExpress设置为false。

在我的情况下, .csproj.user文件重写了.csproj文件事件,但SaveServerSettingsInUserFile被标记为false

 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <UseIISExpress>false</UseIISExpress> <!-- ... --> </Project> 

解决方法是:删除*.csproj.user文件!

我已经设置“ SaveServerSettingsInUserFile ”为True,它为我工作。

 <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <WebProjectProperties> <UseIIS>True</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>50584</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl>http://localhost:50584/</IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl> </CustomServerUrl> <SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile> </WebProjectProperties> </FlavorProperties> </VisualStudio> 

来源: 点击这里

当您使用启用IISexpress,applicationHost.Config(位于%userprofile%\ iisexpress \ config)时,您必须选中“向所有用户应用服务器设置(存储在项目文件中)”选项,以避免您的设置写入在yourProject.csproj.user中 项目设置

这样做与编辑您的project.csproj文件和编写<WebProjectProperties> <UseIIS>True</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>62242</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl>http://localhost:8100/Claims/</IISUrl> <OverrideIISAppRootUrl>True</OverrideIISAppRootUrl> <IISAppRootUrl>http://localhost:8100/Claims/</IISAppRootUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl></CustomServerUrl> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> </WebProjectProperties>如果启用IISExpress并且您的applicationHost.config文件不包含与项目设置相关的条目,必须按下“创build虚拟目录”button完成!

希望这可以帮助

在我的情况下,删除* .csproj.user文件工作正常

我有同样的问题,对我来说,我只需要打开Visual Studio作为pipe理员,这解决了我的问题。

所以简单的右键单击Visual Studio 2012,然后单击“以pipe理员身份运行”。 希望这可以帮助

对于我组合的两个工作的Visual Studio 2015预览与Windows 7 64位:
1.删​​除* .csproj.user文件和
2.解决scheme文件中的<UseIISExpress>false</UseIISExpress>
步骤2的步骤:在Visual Studio中右键单击项目==>卸载===>编辑解决scheme

这就够了

在项目文件x.csproj中注释此行

 <!--<UseIIS>True</UseIIS>--> 

x.csproj:错误:Web项目'x'的URL'http: // localhost / x '被configuration为使用IIS Express作为Web服务器,但URL当前在本地IIS Web服务器上configuration。 要打开此项目,必须使用IISpipe理器从本地IIS Web服务器中删除使用此URL的绑定。

当configuration为使用IIS的项目不能加载,因为它找不到网站(myproject.mycompany.local),即使网站在我的Web浏览器中正常加载,我也在这里登陆。

解决方法是确保IIS 7中的站点绑定将主机名设置为“myproject.mycompany.local”。 要访问您的网站的绑定:

  1. 在IIS 7中,select左侧导航面板中的站点。
  2. 在右侧的动作面板中,点击绑定…

如果您的网站无法在networking浏览器中加载,则可能是因为您的主机文件中没有条目:

 127.0.0.1 myproject.mycompany.local 

如果您的项目是解决scheme的一部分,请打开解决scheme文件(.sln)并编辑项目部分。

 ProjectSection(WebsiteProperties) = preProject UseIISExpress = "false" 

它为我工作。

这个问题今天在VS 2013中毁了我的一天。 我尝试了上述所有,但没有得到项目加载,直到我在IIS中创build一个网站,并在.csproj文件(特别是IISUrl元素)中填充此部分:

 <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <WebProjectProperties> <UseIIS>True</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>81</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl>http://localhost/SomeProject</IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl> </CustomServerUrl> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> </WebProjectProperties> </FlavorProperties> </VisualStudio> 

我有同样的问题,以pipe理员身份运行没有为我工作。

在项目的“.csproj”文件中将<UseIIS>True</UseIIS>为false可能会加载项目,但是在重新启动或closures解决scheme后,该值将返回True。

完成@Cyrus的答案(为我工作)得到一个更简洁的答案,我更专注于项目的csproj.user文件,并find问题的确切来源:设置<UseIISExpress>true</UseIISExpress>为false,然后重新加载项目。 运行良好,无需删除csproj.user文件。 结果是这样的:

 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <ProjectView>ProjectFiles</ProjectView> <UseIISExpress>false</UseIISExpress> <IISExpressSSLPort /> <IISExpressAnonymousAuthentication /> <IISExpressWindowsAuthentication /> <IISExpressUseClassicPipelineMode /> <NameOfLastUsedPublishProfile>My Project's Name</NameOfLastUsedPublishProfile> </PropertyGroup>