DEV Community

loading...
Cover image for Creating my first ASP.NET Core Web API

Creating my first ASP.NET Core Web API

dzifahodey profile image DzifaHodey Updated on ・2 min read

As an Electrical & Electronic Engineering graduate, I finally decided to begin a new journey in the software development world. Although I have beginner knowledge of a few programming languages, frameworks and popular software engineering practices, I would say my learning was not structured.

My first step in this new journey is to learn ASP.NET Core development, and I'm eager to see what it has to offer! In this post, I will describe my first experience with the ASP.NET Core framework using the Microsoft Docs tutorial. I have also included links to key concepts and resources.

Why

First of all, why ASP.NET Core?

ASP.NET Core is a web development framework based on C# that supports multiple platforms such as Windows, Linux and macOS. Being an open source framework, it is very flexible to work with.
This framework features an MVC architecture; Model, View, Controller; which makes it really easy to customize web applications and test APIs (Application Programming Interfaces). APIs are gateways that enable applications communicate with each other.
As I keep working with the framework, I hope to learn more about its usefulness and advantages over other frameworks.

Now, to the process!

Typing
After installing the .NET Software Development Kit (SDK) and getting my Visual Studio Code ready with the C# extension, I was set to start.
Using the integrated terminal in Visual Studio Code, I created a new web API project. One thing I liked was that the new project came with a template that helped give a clearer understanding of how the API worked and was structured.

To develop my API, which was a to-do list tracker, I created my database model and a database context that was set up to use an in-memory database. I then scaffolded the controller to enable it respond to web API requests using CRUD (Create, Read, Update and Delete) operations quickly and asynchronously. Scaffolding is a technique used to generate code for CRUD methods to be used to GET, POST, PUT and DELETE data in the database efficiently.
I included a Data Transfer Object (DTO) model which controls the properties that are returned to the client, and prevents over-posting. Apart from security, the DTO is useful for reducing payload size.

I thoroughly enjoyed the process of creating my first .NET CORE project, and I'm looking forward to exploring its functionality even more.
In my subsequent tasks, I will be optimizing the performance of the API.
Hope you enjoyed this read.! Like and comment :).

Discussion (0)

pic
Editor guide