85

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.

Igor Antonov
  • 1,021
  • 1
  • 8
  • 14
  • 3
    Yeah I'm having the same issue with VS2013 since I've used IIS Express once with this project... Really annoying! – kipusoep Nov 01 '13 at 11:24
  • 3
    Try editing the csproj or csproj.user files and setting `UseIISExpress` to false. http://stackoverflow.com/a/19103452/138938 – Jon Crowell Nov 22 '13 at 18:17
  • 2
    @HeadofCatering , I just had this problem, but UseIISExpress was already set to to false in the projects .csproj file. However, just searching for IIS lead me to find the " True" XML tag inside the csproj file (in ) and simply setting it to be "True" made it so visual studio can load the project again. Hopefully this didn't have any other unintended effects! – mgrandi Dec 20 '13 at 19:04
  • 2
    @mgrandi Mind the typo; setting `True` to `False` did the trick for me too. Thanks for the suggestion! – Dion V. Sep 04 '15 at 07:28

12 Answers12

207

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>
Palec
  • 12,743
  • 8
  • 69
  • 138
Jonah
  • 2,219
  • 1
  • 14
  • 7
  • 48
    Deleting csproj.user finally solved my issue. Thank you! – Bryan Sumter Dec 16 '13 at 12:00
  • Thank you very much, I was breaking my head looking through the csproj settings. Everything looked good. After I deleted the csproj.user file it started loading the project without any complaint ++1 – Esen Jul 18 '14 at 13:32
48

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

Cyrus
  • 2,261
  • 2
  • 22
  • 37
21

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

4

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

zobidafly
  • 275
  • 2
  • 9
  • What version of visual studio is this? I don't have this option in VS Pro 2013 – Matt R Aug 12 '15 at 19:27
  • @Matt R : I got VS2012 pro, so I assume it would be the same for your version. in solution explorer, select your web.application project, right-click and select "properties" -then a tabbed window appears select the "Web" tab and you should see the screenshot I enclosed in the answwer... and sorry for the late answer! – zobidafly Jul 11 '16 at 14:57
3

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

Haddis
  • 31
  • 1
2

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

Gautam Beri
  • 157
  • 1
  • 6
2

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

1

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.

1

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
Seth
  • 6,514
  • 5
  • 49
  • 58
1

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.

Mr Nsubuga
  • 300
  • 3
  • 7
0

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>
Eric Farr
  • 2,683
  • 21
  • 30
0

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>
Homa
  • 134
  • 1
  • 6
  • Should mention that, in ,my case each time I open Visual Studio normally (not as an administrator) the IIS settings return and I have to do the tasks again. – Homa Mar 23 '17 at 15:51