
Building Your First Web API with ASP.NET Core Part 2: Controllers, Models & Your First Endpoint
This is Part 2 of a 4-part series. In Part 1 , we set up the project and got our first response from the default weather endpoint. Now it's time to build something that actually belongs to us. Where We Left Off At the end of Part 1, you had a running ASP.NET Core project with a scaffolded WeatherForecastController . We hit it in the browser and got back JSON — great. But that controller isn't ours, and it doesn't do anything useful for a pizza inventory system. In this part, we'll: Understand how ASP.NET Core controllers work under the hood Create a Pizza model to represent our data Build an in-memory data service Wire up a PizzaController with working GET endpoints How Controllers Actually Work Before writing our own controller, let's decode the sample one that came with the project. Here's the full WeatherForecastController : using Microsoft.AspNetCore.Mvc ; namespace ContosoPizza.Controllers ; [ ApiController ] [ Route ( "[controller]" )] public class WeatherForecastController : Con
Continue reading on Dev.to Tutorial
Opens in a new tab




