Top 8 .NET Web API Best Practices for Efficient Development

Jennie Lee
2 min readMar 28, 2024

--

Looking for a Postman alternative?

Try APIDog, the Most Customizable Postman Alternative, where you can connect to thousands of APIs right now!

Introduction

In this article, we will explore an alternative, developer-friendly way of building REST APIs with ASP.NET 8 using the FastEndpoints library. FastEndpoints is built on top of Minimal APIs introduced in .NET 6 and provides performance benefits without the pain-points of Minimal APIs. By leveraging FastEndpoints and implementing a Vertical Slice Architecture, we can create a clean and maintainable codebase for our REST API.

Building a REST API can be a complex task, requiring careful consideration of various aspects such as routing, request processing, input validation, authentication, and data storage. FastEndpoints seeks to simplify this process and make it more intuitive for developers. With its easy-to-use syntax and powerful features, FastEndpoints offers a seamless experience for building efficient REST APIs.

In this tutorial, we will walk through the process of building a simplified version of Dev.to, a platform where authors can sign up and publish articles. The system will have three main entities: Admin, Author, and Article. We will categorize the features/user stories according to these entities, covering actions such as logging in, approving/rejecting articles, creating/editing articles, and retrieving lists of articles and comments.

To implement our REST API, we will be using a tech stack that includes ASP.NET 8 as the base framework, FastEndpoints for endpoint handling, JWT Bearer for authentication, FluentValidations for input validation, MongoDB for data storage, and SwaggerUI for API visualization. Each component of our tech stack has been chosen for its advantages and compatibility with our project requirements.

Now, let’s dive into the project overview and understand the entities and features/user stories we will be working with in our REST API.

Looking for a Postman alternative?

Try APIDog, the Most Customizable Postman Alternative, where you can connect to thousands of APIs right now!

--

--