Search code examples
asp.net-corevisual-studio-2017iis-express

How do you rename an IIS Express site in Visual Studio 2017?


I've looked for an answer to my above question, but none of the answers at the similarly-named questions below worked for me. The primary difference appears to be that I'm using Visual Studio 2017:

How to change IIS Express site name in Visual studio project

IIS Express Visual Studio Integration - Changing site name

How to rename an IIS Express website in Visual Studio 2012


Solution

  • In VS2017, the file you're looking for is located in a subfolder of your solution folder:

    RootSolutionFolder\.vs\config\applicationhost.config

    It contains all the IIS express configuration for your solution. The easiest way to fix incorrect settings is to remove this file altogether, because Visual Studio will then recreate it.

    If you prefer to edit it, you should look for the <sites> tag, and you should see a list of the configured sites. For example, mine looks like this:

    <sites>
      <site name="WebSite1" id="1" serverAutoStart="true">
        <application path="/">
          <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation=":8080:localhost" />
        </bindings>
      </site>
      <site name="MyAspNetCoreWebsite" id="2">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="D:\MyAspNetCoreWebsite" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation="*:50693:localhost" />
          <binding protocol="https" bindingInformation="*:44363:localhost" />
        </bindings>
      </site>
      <siteDefaults>
        <logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
        <traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
      </siteDefaults>
      <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
      <virtualDirectoryDefaults allowSubDirConfig="true" />
    </sites>
    

    From there, simply find the <site name==""> attribute you want to change.

    Note that you might need to restart Visual Studio.