简体   繁体   中英

Assemble Web API + Web frontend in the same Visual Studio solution

I am learning ASP.Net MVC & Web APIs.

For this moment, I have 2 solutions:

  • Solution A is the Web solution (frontend)
  • Solution B is a Web API Project

For testing : I start solutions A & B ( http://localhost/46433 + http://localhost/3400 ). I successfully can hit api controller in solution B from solution A.

As you can see, each solution live on its own (2 different URLs).

I would like to know if this is possible to assemble everything inside only one solution (with the Web frontend as the default startup project). In this scenario, how is it possible to have the Web API Project running ?

What I would like to achieve:

在此处输入图片说明

For me it is easier to have everything inside only one solution.

In visual studio:

1- On the File menu, click New and then click New Project .

2- In the left pane, select Installed , select Other Project Types, and then select Visual Studio Solutions from the expanded list.

3- In the middle pane, select Blank Solution .

4- Set the Name and Location values for your solution, then click OK.

5- Your empty solution will be created, Then move your projects folder into defined Location in step 4 then in Solution Explorer Right click on the solution name you have created in step 4 then Add Existing project one by one from the location defined is step 4 too.

For multiple startup project do below steps:
1- In Solution Explorer, select the solution (the top node).

2- Choose the solution node's context (right-click) menu and then choose Properties. The Solution Property Pages dialog box appears.

3- Expand the Common Properties node, and choose Startup Project.

4- Choose the Multiple Startup Projects option and set the appropriate actions.

Reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM