Create Web API project

Web API with MVC Project

Visual Studio (2019) includes Web API template which creates a new Web API project with ASP.NET MVC application and includes all the necessary references to get started.
For this, open Visual Studio and click on File menu and click on New Project. This will open New Project popup as below.
image.png
Create Web API project
In the New Project popup, expand Visual C# and select Web node in the left pane. Select ASP.NET Web Application template in the middle pane and enter the name of a project and click OK. (ASP.NET Web Application (.NET Framework) template in Visual Studio 2017.)
This will open New ASP.NET Project popup as shown below.
image.png
Select Web API Template
Select Web API in the above popup. Notice that this has selected and disabled MVC and Web API checkboxes. It means that it will add necessary folders and references for both MVC and Web API.
Click Ok to create a new Web API + MVC project as shown below.
image.png
Web API project
This project is same as default MVC project with two specific files for Web API, WebApiConfig.cs in App_Start folder and ValuesController.cs in Controllers folder as shown below.
image.png
Web API project
The WebApiConfig.cs is configuration file for Web API. You can configure routes and other things for web API, same like RouteConfig.cs is used to configure MVC routes. It also creates Web API controller ValuesController.cs by default. You will learn about WebApiConfig and Controller in the next section.

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.