Building web services using ASP.NET Core Minimal APIs
In older versions of ASP.NET Core, you would build a web service using controllers with an action method for each endpoint, a bit like building a website with ASP.NET Core MVC using controllers and models but without the views. Since .NET 6, you have another, often better, choice: ASP.NET Core Minimal APIs.
Benefits of Minimal API-based web services
In earlier versions of ASP.NET Core, implementing even a simple web service required a lot of boilerplate code compared to alternative web development platforms. For example, a minimal Hello World
web service implementation that has a single endpoint that returns plain text could be implemented using Express.js in just nine lines of code, as shown in the following code:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console...