LibCoder

Web API Development with ASP.NET Core 8: Learn techniques, patterns, and tools for building high-performance, robust, and scalable web APIs

.NET (.NET Core) 1C Agda
Web API Development with ASP.NET Core 8: Learn techniques, patterns, and tools for building high-performance, robust, and scalable web APIs
Автор: Yan Xiaodi
Дата выхода: 2024
Издательство: Packt Publishing Limited
Количество страниц: 804
Размер файла: 6,9 МБ
Тип файла: PDF
Добавил: LibCoder
Оглавление
Preface xv1Fundamentals of Web APIs....1What is a web API?....1What is a REST API?....2The constraints of REST....3A REST API example....4Is my web API RESTful?....5Designing a REST-based API....6Identifying the resources....7Defining the relationships between resources....7Identifying operations....8Designing the URL paths for resources....9Mapping API operations to HTTP methods....12Assigning response codes....14Documenting the API....16RPC and GraphQL APIs....20What is an RPC-based API?....20What is a GraphQL API?....25Real-time APIs....28The problem with API polling....29What is a real-time API?....30Which real-time communication technology is best for your application?....33Summary....342Getting Started with ASP.NET Core Web APIs....35Technical requirements....35Setting up the development environment....36Configuring VS Code....37Checking the .NET SDK....38Creating a simple REST web API project....39Building and running the project....41Building the project....42Running the project....43Changing the port number....45Hot Reload....46Testing the API endpoint....46Swagger UI....46Debugging....53Understanding the MVC pattern....57The model and the controller....57Creating a new model and controller....59Creating a service....62Implementing a GET operation....64Implementing a CREATE operation....65Implementing an UPDATE operation....67Dependency injection....68Understanding DI....69DI in ASP.NET Core....70DI tips....84Introduction to minimal APIs....85Creating a simple endpoint....86Using DI in minimal APIs....87What is the difference between minimal APIs and controller-based APIs?....89Summary....893ASP.NET Core Fundamentals (Part 1)....91Technical requirements....91Routing....92What is attribute routing?....92Mapping HTTP methods to action methods....94Route constraints....95Binding source attributes....97Configuration....99Using appsettings.json....100Using the options pattern....102Other configuration providers....110Environments....114Understanding the launchSettings.json file....116Setting the environment....118Understanding the priorities of configuration and environment variables....122Checking the environment in the code....123Summary....1254ASP.NET Core Fundamentals (Part 2)....127Technical requirements....128Logging....128Using built-in logging providers....128Logging levels....132Logging parameters....134Using third-party logging providers....136Structured logging....138What should/shouldn’t we log?....143Middleware....144What is middleware?....144Built-in middleware....154Creating a custom middleware component....159Summary....1625Data Access in ASP.NET Core (Part 1: Entity Framework Core Fundamentals)....163Technical requirements....164Why use ORM?....164Configuring the DbContext class....166Creating models....166Creating and configuring the DbContext class....168Creating the database....170Adding seed data....173Implementing CRUD controllers....173Creating the controller....174How controllers work....177Basic LINQ queries....178Querying the data....179Filtering the data....181Sorting and paging....182Creating an entity....184Updating an entity....185Deleting an entity....190Configuring the mapping between models and database....192Mapping conventions....192Data annotations....193Fluent API....195Separating the mapping configurations....198Summary....2006Data Access in ASP.NET Core (Part 2 – Entity Relationships)....201Technical requirements....202Understanding one-to-many relationships....202One-to-many configuration....202One-to-many CRUD operations....207Understanding one-to-one relationships....219One-to-one configuration....219One-to-one CRUD operations....222Understanding many-to-many relationships....223Many-to-many configuration....223Many-to-many CRUD operations....228Understanding owned entities....233Summary....2357Data Access in ASP.NET Core (Part 3: Tips)....237Technical requirements 238 Understanding DbContext pooling....238Understanding the difference between tracking versus no-tracking queries....241Understanding the difference between IQueryable and IEnumerable....245Client evaluation versus server evaluation....248Using raw SQL queries....251FromSql() and FromSqlRaw()....252SqlQuery() and SqlQueryRaw()....254ExecuteSql() and ExecuteSqlRaw()....255Using bulk operations....256ExecuteUpdate()....256ExecuteDelete()....257Understanding concurrency conflicts....258Native database-generated concurrency token....261Application-managed concurrency token....263Handling concurrency conflicts....264Reverse engineering....265Other ORM frameworks....268Summary....2698Security and Identity in ASP.NET Core....271Technical requirements....272Getting started with authentication and authorization....272Creating a sample project with authentication and authorization....273Understanding the JWT token structure....285Consuming the API....286Configuring the Swagger UI to support authorization....288Delving deeper into authorization....290Role-based authorization....290Claim-based authorization....295Understanding the authorization process....300Policy-based authorization....306Managing users and roles....312New Identity API endpoints in ASP.NET Core 8....313Understanding OAuth 2.0 and OpenID Connect....316What is OAuth 2.0?....316What is OpenID Connect?....320Integrating with other identity providers....322Other security topics....323Always use Hypertext Transfer Protocol Secure (HTTPS)....323Using a strong password policy....324Implementing two-factorauthentication (2FA)....326Implementing rate-limiting....327Using model validation....327Using parameterized queries....330Using data protection....330Keeping secrets safe....330Keeping the framework up to date....331Checking the Open Web Application Security Project (OWASP) Top 10....331Summary....3319Testing in ASP.NET Core (Part 1 – Unit Testing)....333Technical requirements....333Introduction to testing in ASP.NET Core....334Writing unit tests....335Preparing the sample application....335Setting up the unit tests project....337Writing unit tests without dependencies....339Writing unit tests with dependencies....342Using FluentAssertions to verify the test results....347Testing the database access layer....351How can we test the database access layer?....351Creating a test fixture....353Using the test fixture....355Writing tests for methods that change the database....357Parallelism of xUnit....362Using the repository pattern....365Testing the happy path and the sad path....370Summary....37210Testing in ASP.NET Core (Part 2 – Integration Testing)....373Technical requirements....373Writing integration tests....373Setting up the integration test project....374Writing basic integration tests with WebApplicationFactory....375Testing with a database context....377Testing with mock services....383Testing with authentication and authorization....385Preparing the sample application....385Creating a test fixture....386Creating the test class....386Testing the anonymous API endpoints....387Testing the authorized API endpoints....388Code coverage....398Using data collectors....399Generating a code coverage report....401Summary....40511Getting Started with gRPC....407Technical requirements....407Recap of gRPC....408Setting up a gRPC project....408Creating a new gRPC project....408Understanding the gRPC project structure....409Creating protobuf messages....415Defining a protobuf message....416Understanding field numbers....418Understanding the field types....419Other .NET types....422Creating a protobuf service....430Defining a unary service....431Creating a gRPC client....433Defining a server streaming service....437Defining a client streaming service....440Defining a bidirectional streaming service....443Consuming gRPC services in ASP.NET Core applications....447Updating proto files....449Summary....451Further reading....45212Getting Started with GraphQL....453Technical requirements....454Recap of GraphQL....454Setting up a GraphQL API using HotChocolate....455Adding mutations....459Using variables in queries....462Defining a GraphQL schema....463Scalar types....463Object types....465Retrieving related objects using resolvers....467Field resolvers....469Resolver for a list of objects....472Using data loaders....477Batch data loader....480Group data loader....482Dependency injection....484Using the Service attribute....485Understanding the lifetime of the injected services....486Interface and union types....487Interfaces....488Union types....493Filtering, sorting, and pagination....500Filtering....500Sorting....511Pagination....515Visualizing the GraphQL schema....524Summary....526Further reading....52613Getting Started with SignalR....527Technical requirements....527Recap of real-time web APIs....528Setting up SignalR....528Building SignalR clients....531Building a TypeScript client....531Building a Blazor client....539Using authentication andauthorization in SignalR....543Adding authentication and authorization to the SignalR server....544Adding a login endpoint....547Authenticating the TypeScript client....548Authenticating the Blazor client....551Managing users and groups....553Managing events in SignalR....553Sending a message to a specific user....555Using strongly typed hubs....557Joining groups....559Sending a message to a group....561Sending messages from other services....563Configuring SignalR hubs and clients....565Configuring SignalR hubs....565HTTP configuration options....567Automatically reconnecting....568Scaling SignalR....573Summary....57414CI/CD for ASP.NET Core Using Azure Pipelines and GitHub Actions....575Technical requirements....576Introduction to CI/CD....576CI/CD concepts and terminologies....578Understanding the importance of CI/CD....579Containerizing ASP.NET Core applications using Docker....580What is containerization?....580Installing Docker....581Understanding Dockerfiles....583Building a Docker image....587Running a Docker container....589CI/CD using Azure DevOps and Azure Pipelines....593Preparing the source code....593Creating Azure resources....594Creating an Azure DevOps project....595Creating a pull request pipeline....597Publishing the Docker image to ACR....605Deploying the application to Azure Web Appfor Containers....611Configuring settings and secrets....615GitHub Actions....615Preparing the project....615Creating GitHub Actions....616Pushing a Docker image to ACR....620Summary....62215ASP.NET Core Web API Common Practices....623Technical requirements....623Common practices of ASP.NET webAPI development....624Using HTTPS instead of HTTP....624Using HTTP status codes correctly....624Using asynchronous programming....626Using pagination for large collections....629Specifying the response types....632Adding comments to the endpoints....634Using System.Text.Json instead of Newtonsoft.Json....637Optimizing the performance byimplementing caching....638In-memory caching....639Distributed caching....645Response caching....651Output caching....652What caching strategy should I use?....655Using HttpClientFactory to manage HttpClient instances....655Creating a basic HttpClient instance....656Named HttpClient instances....660Typed HttpClient instances....660Summary....66216Error Handling, Monitoring, and Observability....663Technical requirements....663Error handling....663Handling exceptions....664Health checks....673Implementing a basic health check....674Monitoring and observability....680What is observability?....681Summary....71517Cloud-Native Patterns....717Technical requirements....717Domain-driven design....718Ubiquitous language....718Bounded context....719DDD layers....719Clean architecture....728Microservices....729Web API design patterns....732CQRS....732Summary....760Further reading....760Index....761Other Books You May Enjoy....778

Описание

Ниже — практический обзор по теме «this».

However, with this rapid evolution comes the need to create web API apps that are not only functional but also adaptable, maintainable, and scalable to meet the demands of users and businesses alike. Web API applications have become increasingly significant in recent years, fueled by the ever-accelerating pace of technological advancements. This book draws from the author’s immense technical expertise and decades of experience in software development to help you address this challenge head-on, equipping you with the knowledge and skills required to develop web API apps from scratch.

By providing a deeper understanding of the various protocols implemented by ASP.NET Core, including RESTful, SignalR (WebSocket), gRPC, and GraphQL, supplemented by practical examples and optimization techniques, such as using middleware, testing, caching, and logging, this book offers invaluable insights for both newcomers as well as seasoned developers to meet modern web development requirements. Additionally, you’ll discover how to use cloud platforms such as Azure and Azure DevOps to enhance the development and operational aspects of your application.

By the end of this book, you’ll be fully prepared to undertake enterprise-grade web API projects with confidence, harnessing the latest advancements in ASP.NET Core 8 to drive innovation.

What you will learnBuild a strong foundation in web API fundamentals

Explore the ASP.NET Core 8 framework and other industry-standard libraries and tools for high-performance, scalable web APIs

Apply essential software design patterns such as MVC, dependency injection, and the repository pattern

Use Entity Framework Core for database operations and complex query creation

Implement robust security measures to protect against malicious attacks and data breaches

Deploy your application to the cloud using Azure and leverage Azure DevOps to implement CI/CD

Who this book is forThis book is for developers who want to learn how to build web APIs with ASP.NET Core and create flexible, maintainable, scalable applications with .NET platform. Basic knowledge of C#, .NET, and Git will assist with understanding the concepts more easily.

Если материал оказался полезен — сохраните страницу.

core this book development scalable azure such learn

Частые вопросы

Можно ли скачать «Web API Development with ASP.NET Core 8: Learn techniques, patterns, and tools for building high-performance, robust, and scalable web APIs» бесплатно?

Да, «Web API Development with ASP.NET Core 8: Learn techniques, patterns, and tools for building high-performance, robust, and scalable web APIs» доступна для бесплатного скачивания на нашем сайте в формате PDF. Ссылка на файл находится на этой странице.

В каком формате и какого размера файл?

Книга предоставляется в формате PDF, размер файла 6,9 МБ.

Кто автор и когда вышла книга?

автор — Yan Xiaodi, издательство Packt Publishing Limited, год выпуска 2024, 804 страниц.

О чём книга «Web API Development with ASP.NET Core 8: Learn techniques, patterns, and tools for building high-performance, robust, and scalable web APIs»?

Web API applications have become increasingly significant in recent years, fueled by the ever-accelerating pace of technological advancements.

Похожие материалы