Book Image

Hands-On RESTful Web Services with ASP.NET Core 3

By : Samuele Resca
Book Image

Hands-On RESTful Web Services with ASP.NET Core 3

By: Samuele Resca

Overview of this book

In recent times, web services have evolved to play a prominent role in web development. Applications are now designed to be compatible with any device and platform, and web services help us keep their logic and UI separate. Given its simplicity and effectiveness in creating web services, the RESTful approach has gained popularity, and this book will help you build RESTful web services using ASP.NET Core. This REST book begins by introducing you to the basics of the REST philosophy, where you'll study the different stages of designing and implementing enterprise-grade RESTful web services. You'll also gain a thorough understanding of ASP.NET Core's middleware approach and learn how to customize it. The book will later guide you through improving API resilience, securing your service, and applying different design patterns and techniques to achieve a scalable web service. In addition to this, you'll learn advanced techniques for caching, monitoring, and logging, along with implementing unit and integration testing strategies. In later chapters, you will deploy your REST web services on Azure and document APIs using Swagger and external tools such as Postman. By the end of this book, you will have learned how to design RESTful web services confidently using ASP.NET Core with a focus on code testability and maintainability.
Table of Contents (26 chapters)
Free Chapter
1
Section 1: Getting Started
3
Section 2: Overview of ASP.NET Core
10
Section 3: Building a Real-World RESTful API
19
Section 4: Advanced Concepts for Building Services

What this book covers

Chapter 1, REST 101 and Getting Started with ASP.NET Core, explains some fundamentals of RESTful APIs and how they can be useful when building an application.

Chapter 2, Overview of ASP.NET Core, shows the essential components of the .csproj file. It illustrates the main components of a project: the Startup class and the Program.cs file.

Chapter 3, Working with the Middleware Pipeline, explores middlewares, which are a central part of ASP.NET Core. This chapter walks you through the middleware pipeline and explains how it can handle requests and initialize different services based on them. Furthermore, the chapter covers the different out-of-the-box middlewares provided by ASP.NET Core and how to build a custom middleware.

Chapter 4, Dependency Injection System, introduces you to dependency injection principles and to the concepts behind dependency injection. It shows you how to use dependency injection to initialize components and options inside your application and how to use them inside your controllers.

Chapter 5, Web Service Stack in ASP.NET Core, describes how to create a web service stack in ASP.NET Core. It goes into depth on concerns such as controllers, action methods, action results, model binding, and model validation.

Chapter 6, Routing System, delves into the routing system, which handles HTTP requests. The chapter shows you how to deal with the default routing system of ASP.NET Core.

Chapter 7, Filter Pipeline, covers another essential topic in ASP.NET Core: filters. Filters are a vital component for achieving cross-cutting implementations in our services. The chapter introduces them; it shows how to implement our filters and explores some concrete use cases.

Chapter 8, Building the Data Access Layer, introduces the domain model part. The main topics are related to how to build the domain model and how to access data using object-relational mapping (ORM).

Chapter 9, Implementing the Domain Logic, describes the mediator pattern approach to keeping logic isolated from other application components. The mediator pattern is one way to handle and manage our logic.

Chapter 10, Implementing the RESTful HTTP Layer, explains how to retrieve data from the mediator and use it inside our controllers.

Chapter 11, Advanced Concepts of Building the API, presents some advanced concepts around building APIs in ASP.NET Core. The chapter will cover topics around the soft deletion of resources, and it introduces some good practices for working with asynchronous code in ASP.NET Core.

Chapter 12, The Containerization of Services, gives you a quick introduction to containers and how they can be useful when running your application locally in a sandboxed environment.

Chapter 13, Service Ecosystem Patterns, focuses on the patterns involved when multiple services are part of the same ecosystem.

Chapter 14, Implementing Worker Services Using .NET Core, is dedicated to the new worker template of .NET Core. Workers provide a way to implement small services or daemons that can be used to perform background operations.

Chapter 15, Securing Your Service, talks about securing a service or an API. Besides that, it covers concepts including Secure Sockets Layer (SSL), Cross-Origin Resource Sharing (CORS), and authentication.

Chapter 16, Caching Web Service Responses, covers all the caching choices provided by ASP.NET Core.

Chapter 17, Logging, Monitoring, and Health Checking, shows some best practices for logging and monitoring your application.

Chapter 18, Deploying Services on Azure, shows some examples of how to host a web service in the cloud.

Chapter 19, Documenting Your API Using Swagger, introduces you to the OpenAPI standard and how to implement it in an ASP.NET Core application.

Chapter 20, Testing Services Using Postman, shows how to use Postman to test a web service.