user2884789
user2884789

Reputation: 533

Visual Studio Solution with API and SPA - how to run at the same time

I have a visual studio solution with two projects. Both projects are using .net framework 4.7.2. One project is the SPA (single page app) and the other one is an API web project. In VS, when I start an instance of either project, I am able to use IISExpress through Visual Studio in order to navigate to the local host. However I cannot run both at the same time in order to access the API through the SPA. I have done multiple things using IIS Express command line in order to try to get this to work, but to no avail. Could someone please point me in the right direction?

Thank you

Upvotes: 3

Views: 1956

Answers (4)

user2884789
user2884789

Reputation: 533

In the end I was able to figure out how to use IIS Express to run both at the same time. I edited the application applicationhost.txt in C:\Users\XXX\Documents\IISExpress\config (redacted personal data with Capital Letters)

<sites>
            <site name="API" id="999">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Users\XXX\source\repos\YYY\YYYZ" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:1132:localhost" />
                </bindings>
            </site>
        <site name="FrontEnd" id="989">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Users\XXX\source\repos\XXX\XXXZ" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:8080:localhost" />
                </bindings>
            </site>
        </sites>

Upvotes: 0

Ananthakrishna
Ananthakrishna

Reputation: 517

here is some step to follow: 1. right-click on the solution name. 2. Click on properties. 3. Select 'startup project' under Common properties. 4. Select on multiple startup project. 5. change the action of the two projects from none to 'start' then click apply and ok. 6. After that you can normally run your project by clicking the start icon.

link for referenece.

Upvotes: 0

Jalpa Panchal
Jalpa Panchal

Reputation: 12749

By default, a single project selection is configured as a startup project but you can set multiple projects as well.To start multiple projects at a time in Visual Studio you could follow the below steps:

1)open visual studio and go to Solution Explorer.

2)Click on properties

enter image description here

3)By default, a single project is set as the startup project.

enter image description here

4)Select multiple project options and change project status to start which needs to be started.

enter image description here

5)Run the application, you will see two projects loading in the browser.

enter image description here

enter image description here

Upvotes: 5

Julien Jacobs
Julien Jacobs

Reputation: 2629

This can be done using “Multiple Startup Projects” property of the solution.

Visit the following documentation for step by step instructions

https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2019

Upvotes: 0

Related Questions