From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Creating minimal Web APIs
From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Creating minimal Web APIs
- [Instructor] Minimal web APIs let you implement most of the functionality available in controller-based APIs, but with minimal files and dependencies. Let's go ahead and create one with the .NET CLI. I'll use the same command I did to create a controller-based API, .NET new webAPI. This will create a minimal API by default, so the only other option I'm going to add is the -O option to specify an output directory. I'll now open the new project. If you look at the files and folders here in the VS code project explorer, you'll start to realize why these are called minimal APIs. There's no models folder, no controllers folder, and of course, no views folder. The only actual code file in the project is the program .CS file. You're not limited to a single code file in a minimal API. You can add more if you need to, and just add a using statement at the top of this file to pull in any new namespaces you want to use. Inside here, you'll find the same default weather forecast functionality…