ASP.NET

Create And Consume ASP.NET Core Web API

Contents

Hello to everyone! In this article, I will show you how to develop and test web services using ASP.NET Core. At the end of this post you will learn how to create a web API project and test it in the browser.

First of all, let’s briefly talk about what is ASP.NET Core.

What is ASP.NET Core?

ASP.NET Core makes it easier for developers working on software development with .NET technologies to develop more responsive, reliable and extensible applications.

ASP.NET Core has redesigned the entire ASP.NET infrastructure and combined it with Web API and MVC infrastructures.

Thanks to ASP.NET Core technology, it is possible to create modern applications with less effort and cost in a shorter time.


Prerequisites

Create an ASP.NET Core Web API Project

After starting Visual Studio, click on Create a new project title on the screen that appears.

Visual Studio create a new project
Visual Studio create a new project

Next, type Create an ASP.NET Core Web Application in the search bar and select the first option that appears and click Next. Make sure the selected language is C#.

Create an ASP.NET Core Web Application
Create an ASP.NET Core Web Application

Then select the Project Name, Location and Solution Name and click the create button.

ASP.NET Core Web Application Configure Project
ASP.NET Core Web Application Configure Project

Then select the API option in the window that opens. In addition, I removed the Configure for HTTPS option in order to avoid problems while testing this project with different tools.

Create an ASP.NET Core Web Application Configure for HTTPS

And our project is ready. The project comes ready as an example of the WeatherForecast.cs Model class and the WeatherForecastController.cs class inside the Controllers folder.

ASP.NET Core Web Application Project Structure
ASP.NET Core Web Application Project Structure

Test the API

Let’s run and test it with the ready-made classes without any additions to the project. Run the project by pressing Ctrl + F5. Visual Studio will start a browser and run the project on localhost with a randomly selected port number.

Test API in localhost

Visual studio went to https://localhost:<port>/weatherforecast and worked successfully.

Conclusion

In this post I showed you how to create and run an ASP.NET Core Web API project. Then we examine the ASP.NET Core project structure and files. Stay blowing.

Serkan

Software Engineer. Problem solver. Music practitioner. Thinker. Industrious.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button