VS2012无法加载使用 IIS 和自定义绑定主机的项目-认为它正在使用 IISExpress

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

...
<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>
...

当项目配置为这样的方式,我可以访问站点从 http://custom.host.name/和 VS 自动附加到 IIS 工作进程时调试。

当我重新加载项目(或者通过关闭/重新打开解决方案,或者通过在项目上下文菜单中卸载/重新加载)时,意想不到的事情发生了。项目加载失败,在解决方案资源管理器中,(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.

我试过从 IISExpressapplicationhost.config文件中删除项目站点配置,但是没有用。

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

VS 版本是终极2012更新3。

65141 次浏览

I had the same issue, for me all i had to do was open visual studio as an administrator and this resolved the issue for me.

so simple right click on the visual studio 2012 and click "run as administrator". hope this helps

Opening as an Administrator didn't fix the problem for me. What fixed it for me was opening both the .csproj and .csproj.user files and ensuring that both had UseIISExpress set to false.

In my case, the .csproj.user file was overriding the .csproj file even though SaveServerSettingsInUserFile was marked false.

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

The solution is: delete *.csproj.user file!

This problem was ruining my day in VS 2013 today. I tried all of the above, but didn't get the project to load until I created a Web site in IIS and filled in this section in the .csproj file (especially the IISUrl element):

<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>

when you use enable the use for IISexpress, the applicationHost.Config (located in %userprofile%\iisexpress\config), you have to check the option "Apply Server settings to all users (store in project file)" to avoid your settings written in yourProject.csproj.user project settings

doing this is the same as editing your project.csproj file and writing <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> If you enable IISExpress and your applicationHost.config file doesn't contain the entry related to your project settings, you just have to push the button "Create Virtual Directory" and done!

hope this helps

For me combination of both worked for Visual Studio 2015 Preview with Windows 7 64 bit:
1. delete *.csproj.user file and
2. <UseIISExpress>false</UseIISExpress> in Solution File.
Steps for Step 2:In Visual Studio Right Click on Project==> Unload ===> Edit the Solution

I have set "SaveServerSettingsInUserFile" as True and it worked for me.

<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>

Source : click here

In my case deleting the *.csproj.user file worked fine

This is enough

Comment this line in project file x.csproj

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

x.csproj : error : The URL 'http://localhost/x' for Web project 'x' 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.

I landed here when a project, configured to use IIS, wouldn't load because it couldn't find the web site (myproject.mycompany.local)--even though the web site loaded fine in my web browser.

The solution was to make sure the site's binding in IIS 7 had the host name set to "myproject.mycompany.local". To get to your site's bindings:

  1. In IIS 7, select the site in the left navigation panel.
  2. In the Actions panel on the right, click Bindings...

If you site doesn't load in the web browser either, it's probably because you don't have an entry for it in your hosts file:

127.0.0.1    myproject.mycompany.local

If your project is part of a solution, Open the solution file (.sln) and edit the project section.

ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "false"

It Worked for me.

I had the same issue, running as administrator didn't work for me.

Setting <UseIIS>True</UseIIS> to false in project's ".csproj" file temporarily could load the project, but value was returning to True after restarting or closing the solution.

Completing @Cyrus 's answer (that worked for me) for a more neat answer, I focused more on project's csproj.user file and found the exact source of problem: setting <UseIISExpress>true</UseIISExpress> to false, then reloaded the project. working good, without deleting csproj.user file. result is like this:

<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>