
Explore what a web API is, compare different web API architecture styles, and preview the technologies used to build web APIs with minimal APIs in ASP.NET Core.
learn how web APIs standardize communication between programs over the internet using http protocol, enabling mobile apps and web apps to exchange data through a defined interface.
Design a central web api for a movie application that powers user interactions, movie details, comments, admin tasks, and a database, with frontends like Angular and Maui, and external services.
Compare REST with Soap and GraphQL, and apply REST principles like client-server separation, statelessness, caching, and a uniform interface for scalable web APIs.
Explain soap, an XML-based protocol, and the WSDL standard, contrast its limitations with REST which supports XML, JSON, and CSV, and state that this course will not cover soap.
Explore GraphQL as an alternative to REST in web APIs, focusing on client queries and avoiding endpoint proliferation, with examples fetching movie id, title, and comments.
Explore the dotnet development platform, a cross-platform environment for desktop, web, and mobile apps using C# as the primary language, and trace its evolution from the framework to dotnet five.
Explore how C#, a multi-paradigm, strongly typed language, powers web APIs with ASP.NET Core and supports object-oriented and functional programming.
Discover how ASP.NET Core is a cross-platform framework for building dynamic web applications. Explore routing, a user system, and a dependency injection framework that supports the Dependency Inversion principle.
Compare controllers and minimal APIs for web APIs in net core. Actions map to endpoints, with controllers grouping logic and optional global behavior; minimal APIs offer faster, leaner code.
Explore web APIs with REST and GraphQL, showing how REST architecture simplifies API creation and lets clients decide data, built with ASP.NET Core for fast, multi-platform web apps.
Meet Felipe Gavilan and start building a web api by exploring the basics of an asp.net core web api, and begin the project in this introduction.
Install dotnet 9 SDK on Windows, Linux, or Mac, run the simple installer, then verify installation with dotnet --version to confirm dotnet 9 is installed.
Install Visual Studio Community Edition, choose the ASP.NET Core development workload, optionally use Visual Studio Code, and launch Visual Studio 2022.
Install Visual Studio Code by downloading it from the official site, run the installer wizard, optionally create a desktop icon, and launch the app on Windows, macOS, or Linux.
Install the SQL Server Developer Edition and the SQL Server Management Studio to set up, connect, and manage your database, create tables, and run queries.
Install postman to send http requests to your web api and learn basic request types (get, post, put, patch, delete) plus settings like no cache header and ssl verification.
Create a web api using Visual Studio by starting a new ASP.NET Core empty project named minimal apis movies, then explore Solution Explorer and optional Visual Studio Code workflow.
Create a minimal asp.net core web api using the dotnet CLI with dotnet new web, set the output folder, and explore in VS Code with the C# Dev Kit extension.
Explore project structure, csproj files, and solutions, and learn how dotnet eight, non-null references, implicit usings, and NuGet packages enable reusable code in ASP.NET Core web APIs and class libraries.
Explore how nullable and non-nullable reference types enforce null safety. Learn how implicit usings reduce boilerplate in a program class and how warnings arise when assigning null.
Explore the launchSettings.json file to configure development environment settings, including IIS Express versus kestrel, port numbers, launch URLs like swagger, and environment variables for the ASP.NET Core environment.
Explore how Appsettings.json and environment variables act as configuration providers to supply environment-specific values, such as last name and connection strings, without changing code.
Discover the program class in dotnet apps, configure the builder to set up ASP.NET Core, and use the services and middlewares zones to handle HTTP requests via endpoints.
Create a genre entity and a minimal ASP.NET Core 9 API endpoint that returns an in-memory list of genres such as drama, action, and comedy.
Install dotnet and Visual Studio to run course exercises, build a web API, and explore project vs solution, launch settings, app settings, and the program class endpoint.
Apply rest principles to your ASP.Net Core Web API to build a professional, standards-driven minimal APIs approach that respects software industry standards.
Explore client-server separation, where the server and client operate independently. Learn how cross-origin resource sharing enables requests from other origins to your web API in ASP.NET Core.
Visualize a cors error when consuming a web api from another origin, using a simple html page and fetch to the genres endpoint, and explore enabling access from that origin.
Enable cors in asp.net core by configuring services in the program class with a default policy for origins, methods, and headers, and read allowed origins from app settings via configuration.
Apply CORS policies to endpoints using middleware in ASP.NET Core 9 minimal APIs, enabling a free policy to allow any origin and ensure endpoints are accessible from other origins.
Learn how not using state in a web API improves scalability by ensuring each HTTP request carries all necessary information, avoiding server sessions and enabling future token-based authentication.
Understand how caching serves information with less effort by storing requested data, such as a genres list, to speed up access and reduce database calls, with server-side and client-side examples.
Enable output cache in an ASP.NET core app by adding output cache services, using the middleware before endpoints, and configuring a 15-second expiration to reduce database access.
Explore a macro level layer system that keeps components like the web API and database separate, and preview future services for file storage and a Redis cache repository.
Document your web api with swagger, exposing endpoints via a graphical interface described by an openapi json specification and set up swagger with swashbuckle in development.
Apply restful principles to web api, configure cors to restrict origins, implement simple output cache, and expose endpoints with swagger.
Felipe Gavilan guides you to continue developing the application, create a database, and implement create, read, update, and delete operations using Dapper.
Explore database fundamentals: storing and persisting information in tables of rows and columns, with data types, and the ability to add, edit, and delete through an application or web API.
Create a database named minimal APIs movies using SQL Server Management Studio for the app, including tables for genres, actors, movies, and users.
Create the genres table with an int primary key id, an auto-incrementing identity starting at one, and a non-null name nvarchar(50) to store genre records.
Insert genres data using manual entry and code, writing insert into genres (name) values ('action') and retrieving the new id with scope_identity, before cleaning with truncate table.
Learn how dot net enables data access from your application, allowing insert, update, delete, and read operations via queries and responses. See how SQL Server and Dapper simplify data access.
Dapper automates mapping of database records to C# classes, as in a genres table with id and name, and speeds data access with parameterized queries for security.
Learn to connect an API to a database using a connection string configured by a configuration provider, including server, database, integrated security or user/password, and development trust server certificate.
Install Dapper and Microsoft Data SQL client via NuGet, then create a genres repository with an IGenresRepository interface to abstract data access and enable asynchronous operations.
Insert a new genre into genres using a parameterized query, return the new id via scope_identity, map to the genre class, and return 201 created.
Implement get all and get by id in a Dapper ASP.NET Core repository to read genres, using async queries, optional results, and route endpoints, with caching considerations.
Learn to clean and evict cached data by tagging cache entries and using IOutputCacheStore to evict after creating new genres, ensuring fresh results on subsequent requests.
Learn to order query results with order by, sorting by name or id in ascending or descending order, and apply it to genres in the repository, with swagger refreshed.
Update genre records with dapper by implementing exist and update methods in the genres repository, plus a put endpoint that validates existence and returns a 204 no content.
Delete a genre using a repository and a SQL delete command, understanding why truncate isn't suitable, and expose a delete endpoint with existence checks and a 204 response.
Learn how map group in minimal APIs creates a base configuration for endpoints, reduces repetition, and allows a single change to update all genres routes.
Refactor endpoints from lambdas to named async methods to improve readability and configure each endpoint separately, using type results for ok, not found, and no content, with tests.
Organize minimal apis by grouping endpoints into a genres endpoints class and other resource classes, using an extension method to map routes and show grouped swagger endpoints.
Use data transfer objects to shield entities from the API and prevent over posting, mapping input and output with create genre dto and genre dto via Linq.
install and configure automapper, create profiles to map genre to genre dto and create genre dto to genre, and use IMapper to automate these mappings.
Adopt stored procedures to encapsulate queries, gain SQL Server Management Studio IntelliSense and early error detection, and invoke parameterized operations from your app using command type stored procedure.
Learn to implement and test stored procedures with parameters for genre data, covering get by id, create, update, exist, and delete operations in SQL Server.
Learn how databases persist information, create one with SQL Server Management Studio, and communicate with it from your application using Dapper to simplify the API in the program class.
Create the actors table and the corresponding Actor entity, defining id as a primary key with identity, not-null name and date of birth, and a nullable picture url.
Choose to store images in Azure or locally using a flexible file storage interface, implementing store, delete, and edit operations to return a picture URL for actor endpoints.
Create an Azure storage account in portal and obtain the connection string, then implement a file storage service using blob storage to upload and delete images.
Implement a local file storage service in ASP.NET Core 9 that saves uploaded files to web root, generates a random file name, serves static files, and returns the file URL.
Expose endpoints to get all actors and get an actor by id using a repository and Automapper, returning actor dto and handling not found cases, with caching by tag.
Implement a name-based filter for actors by creating a stored procedure that uses like to match substrings, wire it through the repository and endpoint, and expose actor DTOs via swagger.
Learn how pagination divides actors into pages using a pagination dto with page and records per page, enforcing a max of 50, and applying it to the actors endpoint.
Implement pagination in the app by adding page and records per page parameters, using offset and fetch next in SQL, and exposing total records via the http response header.
Implement a put endpoint to update an actor by id, map with AutoMapper from a create actor DTO, handle optional picture changes via file storage, and return 204 no content.
Implement a delete endpoint for actors that removes the actor from the repository, deletes the actor’s picture from file storage, clears the output cache store, and returns 204 no content.
Define the central movies table with id, title, in theaters, release date, and poster, then build the movie entity to enable crud and support relations to genres, actors, and comments.
Build a movies repository with create, get all (paginated), get by id, update, and delete operations using Dapper and stored procedures in a minimal ASP.NET Core 9 API.
Create an ASP.NET Core 9 movies endpoint for inserting films using DTOs, AutoMapper, from form data with a poster file, wired via a repository, and tested with Swagger and Postman.
Create two movie endpoints: get all with pagination and get by id, map to DTOs, use a repository, enable output caching, and verify with swagger and postman.
Update movies via a minimal API endpoint in ASP.NET Core 9 and Dapper, mapping a create movie dto to a movie entity and refreshing the cache after poster updates.
Delete a movie by id using a repository, check for null, remove the movie and its poster from file storage, clear the cache, and return no content.
Create a comments table linked to movies with a foreign key, enforcing a one-to-many relationship. Define a Comment entity with id, body, and movieId.
Create a comments repository using Dapper in a minimal API, implementing create, get all by movie id, get by id, exists, update, and delete via stored procedures.
Wire up a comments endpoint by creating create and read comment dtos, configuring automapper mappings, and persisting comments via repositories at /movies/{movieId}/comments with 201 created responses.
Create endpoints to fetch all comments for a movie and a comment by id, validate movie, map to comment dto, and return proper 404 or created-at-root url.
Create update and delete endpoints for comments in the asp.net core app, validating movie and comment existence, updating cache, and returning no-content responses.
Map a movie and its comments by running two queries with dapper and a stored procedure, returning a movie object enriched with its comments via query multiple.
Configure a many-to-many relation between movies and genres by adding an intermediate genres_movies table with composite primary keys and foreign keys to genres and movies, plus a GenreMovie entity.
Assign genres to a movie by creating a type integers list for the stored procedure, deleting old associations, inserting new ones, and validating genre existence.
Implement an endpoint to assign genres to a movie, validate movie and genre existence, handle empty lists, and return 204 no content or 400 bad request.
Configure a many-to-many relationship between actors and movies with an intermediate table and a composite primary key, including actor_id, movie_id, order, and character fields.
Create an in-memory actors list type, build a search procedure to assign actors to a movie while preserving order, and wire it to a sql-based web api repository.
Create an endpoint to assign actors to a movie using a dto with actor id and character, validate existing actors, map assignments via AutoMapper, and return no content on success.
Fetch a movie by id with its genres and actors using joins to the genres_movies and actors_movies tables, map to dtos, and configure Automapper projections.
Explore configuring entity relationships with Entity Framework Core, learn to receive and store files in a web API using Azure Storage or local storage, and implement CRUD for all entities.
Learn how validations ensure client input meets business rules. Discover strategies for error handling to sustain a good user experience when issues arise.
Validate user data in minimal APIs with FluentValidation. Install the library and configure validators from the program assembly to enforce business rules, including asynchronous validations.
Enforce business rules with validation rules that ensure the genre name is not empty, using a create genre DTO validator and validate async to return a 400 error.
Customize validation errors in a minimal API by configuring a DTO validator in Visual Studio, using field name placeholder to produce 'field name is required' messages and verify with swagger.
Apply multiple validations on a single property, including a 150-character max length for the name with a custom error message, and observe simultaneous rules preventing long inputs.
Create and apply custom validations beyond default rules, such as enforcing that a string starts with an uppercase letter, using a Must rule and a dedicated validation method.
Implement asynchronous validation in fluent validation to prevent duplicate genre names by querying the database with a stored procedure, handling insert and update cases via a repository and dependency injection.
Inject a create genre dto validator into the update method, validate input, extract the route id with IHttpContextAccessor, parse it safely, and update the genre while preventing duplicates.
Validate multiple properties in a create actor DTO with a validator, enforcing name not empty and max length 150, plus a minimum date of birth of 1901 on the endpoint.
Create a static ValidationUtilities class to centralize validation messages for reuse across genre and actor DTO validators, including non-empty, maximum length, first letter uppercase, and greater than date method.
Learn how filters in minimal APIs centralize parameter validation and intercept endpoint execution before and after, demonstrated on the genres get by id endpoint.
Access endpoint parameters inside a filter by position or by type using context arguments, retrieving int, repository, and mapper values, and safeguard against order issues by using specific types.
Centralize validations with a genre validation filter for minimal APIs. The filter injects IValidator, validates the DTO, and short-circuits on errors for reuse across entities.
Implement a generic validation filter to centralize validation for any dto, reuse existing logic, and apply it to genre and actor endpoints via the endpoint filter interface.
Create a comment DTO validator, inheriting from Abstract Validator, enforce a not empty body rule, apply it to create and update endpoints, and verify a 400 for an empty body.
Validate movie data by building a movie dto validator that enforces a non-empty title and a 250 character max, with validation applied to create and update endpoints.
Explore robust error handling in minimal APIs by validating data types, preventing sensitive error exposure, and returning JSON problem details via exception handling and status code pages in production.
Modify the exception handler to customize the error page and return a customized response with type and error message for status 500.
Save application exceptions to a central database using a unique identifier, capturing exception messages, stack traces, and timestamps to enable production debugging and cross-database aggregation.
Implement validations in minimal APIs, apply filters to intercept endpoint execution, and handle errors by saving them to a database.
Secure your web API by implementing a user system with permissions, teaching who can do what and preventing unauthorized actions in a minimal ASP.NET Core 9 and Dapper setup.
Authenticate users with identity, issue a signed jwt with claims like name and email, then use the token in a header to access protected endpoints and enforce administrator actions.
Protect endpoints by configuring authentication and authorization with JWT bearer. Add authentication and authorization services, apply app.use authorization, and verify access with swagger showing 401 until a token is provided.
Create and test JSON web tokens without a user system using the dotnet user jwt s tool, verify with postman via bearer tokens, and inspect issuer, audience, and secrets.
Configure seven identity tables—roles, role claims, users, users claims, users logins, user roles, and user tokens—using a script and explain each table's function for authentication, authorization, and JWT support.
Create a custom user store and repository to centralize identity operations in ASP.NET Core 9, implementing get by email and create user via stored procedures.
Implement the user store by injecting the user repository in the program. Support create, get by email, and password hash, and configure identity core with the store.
Configure your app to emit and validate jwt tokens by managing a base64 secret key via user secrets and using a keys handler for issuer signing keys.
Define a user credentials dto with email and password, validate them, create an identity user on register, and build a JWT with email claims for the authentication response.
Implement a login endpoint that validates credentials via user and sign-in managers, uses generic error messages to prevent user enumeration, and enables lockout on failure with a token and expiration.
Add a non-null user id to the comments table, create a foreign key to users with cascade delete, and update the API, entity, and repository to support the user id.
Learn to securely obtain the current user's id in an asp.net core 9 app using HttpContext claims and identity user manager, implement a user service, and protect endpoints with authorization.
Enforce that only the comment creator can update or delete a comment, returning forbidden when the user id differs, after validating the comment exists in the minimal API.
Configure claim-based authorization by creating the is admin policy that requires an admin claim, then enforce it on post, put, and delete endpoints for actors, genres, and movies.
Modify the user store to support claims by implementing claim-related methods in the repository, using Dapper to insert, retrieve, assign, and remove user claims.
Learn to assign and remove admin claims using a users_claims table, validate via edit claim dto, secure endpoints with admin authorization, and refresh JWTs to reflect new claims.
Implement a silent token renewal endpoint to extend expiration while users stay active, retrieving the current user, building a new token, and testing with Postman.
Define authentication as who is who and authorization as what they can do, then protect endpoints with JWTs to enable account creation and login.
Felipe Gavilan guides you through new scenarios not yet covered, and traces logging, model binding, and swagger in greater depth within building minimal APIs with ASP.NET Core 9 and Dapper.
Learn to implement logging in minimal APIs using ILogger, create category-specific loggers, and manage log levels (trace to critical) via app settings to monitor production activity.
Master model binding in ASP.NET Core 9 by receiving data from query strings, headers, body, routes, forms, and services, using from attributes to map values to parameters.
Learn to reduce endpoint parameter counts by using the as parameters attribute to pass multiple values via a DTO, demonstrated on get by id and create endpoints, with validation caveats.
bind async demonstrates mapping a pagination dto from the query string in a minimal api, using http context, query string, and manual parsing for page and records per page.
Enable swagger to render a UI for advanced binding by adding pagination parameters to endpoints through OpenAPI options and a reusable extension method, applied to actors and movies endpoints.
Customize the swagger page by configuring OpenAPI info with title, description, contact, and MIT license, then view immediate updates to the web API documentation.
Discover how to document endpoints by adding summaries, parameter descriptions, and request body descriptions in OpenAPI using Visual Studio, for clearer genre update endpoints.
Discover how to expose file upload in swagger via openapi for post and put endpoints in actors and movies, including a picture field and preparing for JWT authentication.
Configure swagger to send JWT with an OpenAPI security scheme and header api key, then use authorize to apply a security requirement across endpoints.
Use a Swagger authorization filter implemented as an operation filter to personalize endpoint metadata by applying security requirements only to endpoints with authorize attributes, leaving public endpoints unprotected.
Create a movies filter dto and a pagination dto to enable paginated filtering and ordering of movies by title, genre id, and order by field with ascending.
Apply dynamic filtering to a movies query with optional title, future releases, in theaters, and genre id, plus pagination.
Learn to dynamically order query results by title or release date using case expressions in a stored procedure, and switch between ascending and descending orders with a field delimiter.
Define an enum with title and release date to delimit the ordering field in an ASP.NET Core 9 minimal API using Swagger extensions.
Explore why in-memory output caching falls short for multi-instance apps. Learn to implement a distributed cache with Redis, including local development and Azure Cache for Redis options.
Configure redis in the cloud for testing, activate your account, choose Azure, access a database with a public endpoint and password, and use it from ASP.NET Core.
Install and configure Redis output caching in ASP.NET Core 9, wire up Stack Exchange Redis, and validate a distributed cache across API instances using a public endpoint and Redis Insight.
Learn practical logging in .NET Core, explore model binding options, and document your API with Swagger. Implement Redis distributed caching to scale across multiple app instances.
Publish your minimal API to Azure and IIS and set up continuous delivery with Azure DevOps to streamline deployments.
Publish and configure a minimal API to Azure App Service, connect to Azure SQL Database via environment variables and app settings, publish, test, and debug startup errors in production.
Debug a startup failure by inspecting the Azure console, restore allowed origins in app settings, and republish to fix a 500 error during registration.
Learn to diagnose production errors with Application Insights and Azure portal, reproduce failures, view stack traces, and fix a missing key by configuring environment variables in app settings.
Deploy a minimal API to IIS by installing the hosting bundle, enabling IIS, and publishing the app to inetpub. Configure production appsettings, sql server authentication, and a swagger-enabled API.
Automate building and deploying applications with Azure DevOps from GitHub, implementing continuous integration and continuous delivery to achieve predictable, repeatable production deployments.
Configure a continuous integration pipeline in Azure DevOps to build a minimal APIs project with a SQL Server database project, import the database, produce a dacpac, and publish artifacts.
Master continuous delivery in Azure DevOps by configuring release pipelines with artifacts, deploys to Azure App Service and SQL using dacpac, and automatic production deployment from Git updates.
Publish your API by deploying to cloud options like Azure App Service, which manages the server, or on IIS in a cloud VM, then automate with Azure DevOps from GitHub.
Celebrate completing this course and look forward to the next course as you apply it to your professional life.
Learn how to develop Minimal APIs with ASP.NET Core from scratch with this amazing course.
We are going to see the entire life cycle of developing a Web API, from creating the solution, developing the endpoints, working on resource manipulation, to putting it into production in Azure and IIS.
In this course we will do a project which you will be able to publish and show as part of your portfolio.
We will also learn how to use Azure DevOps to configure a Continuous Integration and Continuous Delivery pipeline, to be able to publish your projects from their source code in Github, Bitbucket, or any other GIT repository provider.
Some of the topics we will see are:
Creation of REST Web APIs
Create a database
Use Dapper to read, insert, update, and delete records from a database
Create a user system so that our clients can register and log in to the Web API
We will use Json Web Tokens (JWT) for authentication
Claims-based authorization, so that only some users can use certain endpoints
Using cache to have a faster application
Using Redis for distributed cache
Web APIs are fundamental in modern web development. Since they allow us to centralize and protect the logic of our solutions. In addition, it is in a Web API that we typically have access to a central database with which all your users can communicate. Whether you build a social network, a delivery application, or even an office app, a Web API allows you to work on the back-end of mobile applications (Android, iOS, MAUI, etc.), web (React, Angular, Blazor, Vue, etc.), desktop, among others.