VS 2012 can't load project which uses IIS with

2019-01-16 10:32发布

I have an ASP.NET project which uses IIS. IIS site is configured to use custom binding host name. Project file contains following settings:

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

When project is configured in such a way, I can access the site from http://custom.host.name/ and VS automatically attaches to IIS worker process when debugging.

When I reload project (either by closing/reopening solution or by unload/reload in project context menu), something unexpected happens. Project fails to load, (load failed) is displayed to the right of project name in solution explorer and message box is shown with the following message (it's also displayed in the Output window):

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.

I have tried removing project site configuration from IIS Express applicationhost.config file, but it didn't help.

I don't encounter this problem when mapping project to IIS Application under default site.

VS version is Ultimate 2012 Update 3.

12条回答
Explosion°爆炸
2楼-- · 2019-01-16 11:10

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>

查看更多
唯我独甜
3楼-- · 2019-01-16 11:11

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

查看更多
贪生不怕死
4楼-- · 2019-01-16 11:12

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

查看更多
Emotional °昔
5楼-- · 2019-01-16 11:13

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.

查看更多
Viruses.
6楼-- · 2019-01-16 11:14

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>
查看更多
【Aperson】
7楼-- · 2019-01-16 11:16

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

查看更多
登录 后发表回答