Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...