Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS Express - Visual Studio - Running multiple sites on the same port

I have multiple APIs that use the same port (8888). These APIs are part of different solutions.

http://localhost:8888/api1

http://localhost:8888/api2

....

When I run any of the APIs in visual studio 2013 (hit F5), iis express starts and all of the APIs are running. This happens even though the APIs are part of different solution. I can see them when I click on the iis express icon under View Sites.

I installed VS 2015 and when I run one API in visual studio the other APIs do not run. I cannot even run the other APIs in the other solution since I get:

unable to launch iis express.. port is in use

how can I get the other APIs to run when I run any API? I need to mimic the behavior that exists in VS 2013 in VS 2015.

Thanks.

like image 987
user1253073 Avatar asked May 03 '16 15:05

user1253073


People also ask

What port is IIS Express running on?

iisexpress /path:c:\myapp\ /port:80 This command runs the site from c:\myapp folder over port 80. Run your site using one of the following: Use /config to run a site from a configuration file.

Can I access IIS Express from another machine?

Normally when you run an application in IIS Express, it's only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well. Open* D:\Users[YourName]\Documents\IISExpress\config\applicationhost. config *and find your site.

Does IIS Express use web config?

Does IIS Express use the same configuration system as IIS? Yes, IIS Express uses the same applicationhost. config and web.

How do I change IIS Express settings in Visual Studio?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.


2 Answers

I solved this for a similar scenario, although in my case I chose to run IISExpress via the command line and passed through the config file as an argument.

  1. Edit the applicationhost.config file. I found mine via the folder path %USERPROFILE%\Documents\IISExpress\config
  2. Locate the <sites> section (found under <system.applicationHost>)

As an example, I have two applications that I want to host simultaneously on port 80 on localhost:

<sites>
    <site name="test" id="1" serverAutoStart="true">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath" />
        </application>
        <application path="/api1" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath\api1" />
        </application>
        <application path="/api2" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath\api2" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation=":80:localhost" />
        </bindings>
    </site>
<!-- other settings  relevant to your installation of IISExpress-->
</sites>

The key things I had to do to get this working was:

  1. Make sure applicationhost.config is well-formed XML
  2. Make sure you specify the root path in addition to the two api application paths
  3. serverAutoStart="true" ensures the site starts when IISExpress is called
  4. All the applications share the same applicationPool
  5. I defined just one site and bundled in all my applications as sub paths
like image 146
ivor Avatar answered Oct 18 '22 16:10

ivor


Update to this in Visual Studio 15+ the IIS config folder is in the projects hidden .vs folder [ProjectFolder]/.vs/[ProjectName]/config/applicationhost.config Other than that, Ivor's Answer still worked for me.

like image 25
Ike Rolfe Avatar answered Oct 18 '22 17:10

Ike Rolfe