• Post category:StudyBullet-14
  • Reading time:16 mins read


Learn Web API, MVC, Security, CRUD, CORS, Swagger, and Reusability are all covered in this course.

What you will learn

What is a Web API?

Build a Web API Project

Use PostMan and Swagger to Test API Calls

Configure your Web API using Config Classes

Determine the Return Type to Use

Format Data as JSON or XML

Setup Web API Routes

Add Logging to your Web API Calls

Add Exception Handling to your Web API Calls

Develop a Complete Set of CRUD APIs

Call your Web APIs from JavaScript/jQuery

Add CORS to Allow Cross-Domain Calls

The Basics of Securing Web APIs

Calling Web APIs Asynchronously

Description

If you need other developers to access data within your private domain, Web APIs are the best way to accomplish this. Using Web APIs, you write code behind a firewall to access your data and expose just what you want to the outside world. With Microsoft you can write Web APIs using the popular MVC paradigm and this is what you are going to learn in this course. Even if you have never created a Web API before, this course guides you step-by-step through the entire process.

In this course you are provided with an overview of Web APIs in general. You then build an MVC Web API project and learn to consume Web APIs using Postman and Swagger. You learn how to configure the project to return different types of data such as JSON and XML. The basics of routing and how to add logging and exception handling is illustrated. You then build a set of CRUD APIs to allow a developer to interact with your database. You are going to see how to call your APIs via JavaScript/jQuery and how CORS is added to allow cross-domain access. Finally, the basics of securing your Web APIs is covered.

How Are You Going To Learn All This?


Get Instant Notification of New Courses on our Telegram channel.


All the demos you are shown during this course are backed up with a set of labs for you to perform. Walking through these labs step-by-step ensures that you understand the concepts illustrated in each lesson.

  • ~88 demos
  • ~65 questions
  • ~75 hands-on labs

Who am I?

My name is Paul D. Sheriff and I have been teaching developers since 1986 through video, blogs, articles, speaking at major conferences and user groups, and in-person training at small and enterprise (Fortune 500) companies. My students have said I have an easy-going manner and have a talent for breaking complicated topics into an easy-to-understand format. I consistently have very high ratings on my courses. I believe you need to learn by doing and that is why I offer so many hands-on labs within my courses.

English
language

Content

MVC Web API Development: Quick Course Overview

Quick Overview of this Class

MVC Web API Development: Course Overview

MVC Web API Development: Course Overview

Web API Fundamentals

What is a Web API
HTTP Status Codes and Verbs
ASP.NET and It’s Components
Routes, Endpoints and Dependency Injection
Middleware Fundamentals
Minimal Web API Overview
MVC Web API Overview
Test your knowledge of Web API Terms and Concepts

Create a Web API Project and Test using Swagger/Postman

Create Web API Project Using VS Code
Create Web API Project Using Visual Studio 2022
Test Web API Calls Using Postman
Using Swagger/Open API to Test API Calls
Understanding and Commenting Program.cs
Test your knowledge of Creating a Web API Project
Finished Lab Samples
Sample Code Demonstrated in this Section

Getting Started with Controllers and Return Types

Adding Product Entity & Repository Classes
Add Product Controller to Return a List of Products
Get a Single Product from the Product Controller
Using the IActionResult Return Type for a List
Using the IActionResult Return Type for a Single Product
Alternatives to the StatusCode() Method
Add Multiple Response Types to Action Methods
Use ActionResult<T> Generic for Returning Data
Test your knowledge of Controllers and Return Types
Finished Lab Samples
Sample Code Demonstrated in this Section

How Routing Works

Overview of Routing and Applying the [Route] Attribute
Multiple URLs on the Same Endpoint
Get a Product by Category ID
Pass Multiple Query Parameters
Pass Multiple Query Parameters as a Query String
Using Parameter Constraints
Test your knowledge of Routes and Parameters
Finished Lab Samples
Sample Code Demonstrated in this Section

Using Dependency Injection

What is Dependency Injection and Why Use It
Service Lifetimes of Injected Objects
Demonstration of a Scoped Lifetime
Demonstration of a Singleton Lifetime
Using an Interface with Dependency Injection
Test your knowledge of Dependency Injection
Finished Lab Samples
Sample Code Demonstrated in this Section

Add Logging to Web API Calls

Introduction to Logging in ASP.NET Core
Using the Built-In Logging to the Console Window
Control the Log Levels Through the appsettings File
Logging an Object
Test your knowledge of logging
Finished Lab Samples
Sample Code Demonstrated in this Section

Add Exception Handling to Web API Calls

The Built-In ASP.NET Unhandled Exception Handler
Create Your Own Exception Controller
Development vs Production Exception Handling
Create a Production Profile in Visual Studio
Handling a 404 Status Code
Log Exceptions and Info Messages to Different Files
Log Exceptions in your Catch Blocks
Test your knowledge of Exception Handling
Finished Lab Samples
Sample Code Demonstrated in this Section

Create Base Controller Class to Reduce Duplicate Code

Create a Custom Base Controller Class
Add Exception Handling to Base Controller Class
Add Serialization of Objects to Base Controller Class
Test your knowledge of a base controller class
Finished Lab Samples
Sample Code Demonstrated in this Section

Reading Configuration Settings Efficiently

Reading Configuration Settings from JSON File
Read Settings into Object, Inject Object
Read Settings, Assign to Each Property in Class
Assign Config Settings Directly to Class
Read Settings and Bind to Class in Program.cs
Dynamic Configuration Settings Using IOptionsMonitor<T>
Test your knowledge of reading configuration settings.
Finished Lab Samples
Sample Code Demonstrated in this Section

Formatting JSON and XML Input and Output

Using Attributes to Affect JSON Serialization
Format JSON Using Global Options in Program.cs
Ignore All Read-Only Properties
Return XML From Web API Calls
Consuming XML in a Post() Method
Test your knowledge of JSON Serialization
Finished Lab Samples
Sample Code Demonstrated in this Section

Call Web APIs From Client-Side and Setup CORS

Create an MVC Website From Which to Make API Calls
Call Web API via JavaScript
Configure CORS to Allow Incoming Web API Calls
Test your knowledge of CORS
Finished Lab Samples
Sample Code Demonstrated in this Section

Organizing the Program.cs File for Readability

Create a Constants Class
Create a Services Collection Extension Class
MVCBuilder and Host Extension Classes
Create Web Application Builder Extension Class
Create Repository Classes Extension Method
Finished Lab Samples
Sample Code Demonstrated in this Section

Securing Web APIs with JSON Web Tokens

Security in ASP.NET
Turn on Authentication and Add [Authorize] Attribute
Overview of JSON Web Tokens
Adding JWT to a Web API Project
Register JWT as the Authentication Scheme
Handling Unauthorized Calls (401 Status Code)
Creating the Entity Security Classes
Creating the Security Manager Class
Create a Security Controller to Generate a JWT
Display the Contents of a JWT
Add JWT Support in Swagger
Securing an Endpoint Using Claims
Test your knowledge of ASP.NET security
Finished Lab Samples
Sample Code Demonstrated in this Section

Get Data From a Database Using the Entity Framework

Add the Entity Framework to the Web API Project
Add Data Annotations to the Product Class
Create the DbContext Class
Add the DbContext Class to the DI Services Collection
Read Product Data from the Database
Test your knowledge of the Entity Framework
Finished Lab Samples
Sample Code Demonstrated in this Section

Adding, Editing, Deleting, and Validating Data

Add Methods to the Interface and Repository Class
Insert Products into the Product Table
Update Products in the Product Table
Delete Products in the Product Table
Validating Product Data Using Data Annotations
Finished Lab Samples
Sample Code Demonstrated in this Section

Create Searching Methods

Create a SearchBase and a ProductSearch Class
Add Search Methods to Product Repository Class
Add Search Methods to IRepository Interface
Add a Search Route to Product Controller
Finished Lab Samples
Sample Code Demonstrated in this Section

Making Asynchronous API Calls

Introduction to Asynchronous
How Asynchronous Web API Calls Work
Introduction to async, await and Task<T>
A Simple Sync/Async Demonstration
Create Async Repository Class
Create Async Controller & Get all Products Asynchronously
Get a Single Product Asynchronously
Create Search, Insert, Update, Delete Async Methods
Test your knowledge of asynchronous programming
Finished Lab Samples
Sample Code Demonstrated in this Section