VS 2012 can't load project which uses IIS with custom binding host - thinks it's using IIS Express

不问归期 提交于 2019-11-27 05:18:14

问题


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.


回答1:


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>



回答2:


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




回答3:


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

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




回答5:


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




回答6:


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




回答7:


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




回答8:


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.




回答9:


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



回答10:


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.




回答11:


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>



回答12:


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>


来源:https://stackoverflow.com/questions/17657607/vs-2012-cant-load-project-which-uses-iis-with-custom-binding-host-thinks-its

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!