Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net-core

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

like image 912
John John Avatar asked Oct 18 '25 12:10

John John


1 Answers

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

like image 84
Md Farid Uddin Kiron Avatar answered Oct 20 '25 17:10

Md Farid Uddin Kiron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!