Debugging multiple web application within one IIS Express site

29 views Asked by At

The new SDK style project format no longer supports running multiple web applications inside a single website, or does it?

Legacy project format

With the legacy project format is was possible to debug multiple website projects at once, each running in a different IIS Express application.

For example:

  • http://localhost:12345 running WebApplication1
  • http://localhost:12345/WebApplication2 running WebApplication2

Visual Studio takes care of applicationhost.config, creating a single 'website' and an 'application' per project. All 'applications' are linked to the same Clr4IntegratedAppPool application pool. Visual Studio starts the 'Clr4IntegratedAppPool' by launching iisexpress.exe. That all works fine.

SDK style project format

I cannot get the configuration described above to work for SDK style projects. The urls have now been configured in launchSettings.json under iisSettings/iisExpress/applicationUrl. Again, Visual Studio alters applicationhost.config accordingly. The problem however is that is does't use the same application. It creates a separate application pool per project, as can be seen here:

<site name="WebApplication1" id="2">
  <application path="/" applicationPool="WebApplication1 AppPool">
    <virtualDirectory path="/" physicalPath="C:\IISExpressDemo\WebApplication1" />
  </application>
  <application path="/WebApplication2" applicationPool="WebApplication2 AppPool">
    <virtualDirectory path="/" physicalPath="C:\IISExpressDemo\WebApplication2" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:12345:localhost" />
  </bindings>
</site>

Having two application pools, requires two instances of IIS Express running. But only one can use port 12345, so we get the following error message:

Error

An error occurred launching IIS Express. Unable to launch the configured Visual Studio Development Web server.Port '12345' is in use.

Question

Is it somehow possible to run and debug multiple website projects inside a single website under IIS Express? Or can we control the application pool? Or ...?

Remarks

You can find a simple example with the described problem at https://github.com/EdwinEngelen/IISExpressDemo.

This might not be the best practice for modern .NET application, but the application we're working on here is still on .NET Framework 4.7.2. Migrating to SDK style projects (with help of MSBuild.SDK.SystemWeb) is part of our migration path to .NET.

Thank you in advance!

0

There are 0 answers