Home > Net >  Can I have asp.net core mvc and web api as single project
Can I have asp.net core mvc and web api as single project

Time:10-19

We want to build an asp.net core web application. it contains MVC part for returning Views and API to return JSON and have Restful services for our web application.

So can I have MVC and Web API inside the same project? as currently when i want to create a new project inside .NET 6.0 i have to select the either MVC or Web API type :-

enter image description here

CodePudding user response:

So can I have MVC and Web API inside the same project? as currently when i want to create a new project inside .NET 6.0 i have to select the either MVC or Web API type :-

Certainly you can. What all you need is, you should have one solution. Furthermore, within the solution, you ought to create two project. One for MVC application and another for Web API application. Here is the simulation how you can achieve that:

enter image description here

Project Architecture Would be Like:

enter image description here

If you want to run two project together:

  1. Go to your solution and right click on it
  2. Select Property
  3. Choose Multiple Startup Project

enter image description here

enter image description here

  • Related