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

Igo*_*nov 83 asp.net iis iis-express visual-studio-2012

我有一个使用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>
...
Run Code Online (Sandbox Code Playgroud)

当以这种方式配置项目时,我可以从中访问该站点,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.
Run Code Online (Sandbox Code Playgroud)

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

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

VS版本是Ultimate 2012 Update 3.

Jon*_*nah 201

以管理员身份打开并没有为我解决问题.什么固定它为我打开了双方.csproj.csproj.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>
Run Code Online (Sandbox Code Playgroud)

  • 删除csproj.user最终解决了我的问题.谢谢! (47认同)

Cyr*_*rus 47

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


Lia*_*kat 21

我将" 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>
Run Code Online (Sandbox Code Playgroud)

来源:点击这里