We will add Web API controller in the Controllers folder and configuration class in the Configuration folder. Now, create Controllers and Configuration folder in the HelloWebAPI project as shown below. The following Web API packages are displayed upon successful installation. Select Microsoft ASP.NET Web API2.2 package and click on Install as shown below.Īccept the license agreement and continue. This will display all the Web API related packages. Select Online in the left pane and search for webapi (make sure that internet connection is on). This will open Manage NuGet Packages popup. Right Click on the project and click Manage NuGet Packages. Now, we need to add latest Web API references using NuGet Package Manager. This will create an empty "HelloWebAPI" project. In the above popup, select Empty as a template and click ok. Clicking on OK will open a popup as shown below. Enter a name of the project, location and Solution name as shown above. Select Web template in the left pane and ASP.NET Web Application in the middle pane. This will open New Project popup as below. Here, we will create a new stand-alone Web API project without MVC project.įor this, open Visual Studio 2013 for Web -> go to File menu and select New Project. Thus, you can create Web API project with MVC to get started on your application. You will learn about WebApiConfig and Controller in the next section. ![]() It also creates Web API controller ValuesController.cs by default. You can configure routes and other things for web API, same like RouteConfig.cs is used to configure MVC routes. The WebApiConfig.cs is configuration file for Web API. ![]() 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. It means that it will add necessary folders and references for both MVC and Web API.Ĭlick Ok to create a new Web API + MVC project as shown below. Notice that this has selected and disabled MVC and Web API checkboxes. This will open New ASP.NET Project popup as shown below. (ASP.NET Web Application (.NET Framework) template in Visual Studio 2017.) Select ASP.NET Web Application template in the middle pane and enter the name of a project and click OK. In the New Project popup, expand Visual C# and select Web node in the left pane. Visual Studio (2019/2022) 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.įor this, open Visual Studio and click on File menu and click on New Project. You can create a Web API project in two ways. Here, you will learn how to create a new ASP.NET Web API project using Visual Studio.
0 Comments
Leave a Reply. |