Getting Started: Building Web API using ASP .Net Core

Darshan Unadkat
3 min readMay 11, 2020

In this article, we will create a web API using ASP .Net Core.

I am using Visual Studio with Windows 10. There might be some difference in your case if you are using LINUX or MAC.

Content

  • Prerequisites
  • Creating an ASP.NET Core Web API Project
  • Files in the project
  • Build and Run the Project

Prerequisites

To achieve this task, we need to have .Net Core 3.0 SDK installed in your system. It can be verified by typing given command in your command prompt window.

If it shows error, the download it from here and install.

Creating an ASP.NET Core Web API Project

To create a new project, open Visual Studio in your system and follow the given steps one by one.

After opening Visual Studio, the initial screen will look like this:

Type ASP .Net Core Web Application in the search bar and select the option as shown in the above picture and click on Next. This will launch the next screen:

Enter Project name in first field and select the preferred location of the project in the Location. I have entered Project name as DemoProject. After that, click on Create button which will scaffold a new project.

After that, select the template for creating an ASP .Net Core Web Application. Here we will choose API to create a WEB API. After that, click Create.

Files in the Project

This image shows the structure of newly created project which contains:

WeatherForecastController.cs: It contains the business logic of our project.

WeatherForecast.cs: It represents the model for the WeatherForecast.

launchSettings.json: It contains the information of the project related to the configuration of the launch settings.

Build and run the Project

To run the project, simply press the run button in Visual Studio, which will run your project in the default/selected browser.

The default port number is 5001 and URL is https://localhost:5001/weatherforecast and the output of this API will be JSON format like given below:

I will cover CRUD operation in the next article.

Hope this helps.

--

--