Customizing ASP.NET Core 6.0 - Second Edition

Book description

Take your ASP.NET Core web development skills to the next level by discovering hidden behaviors and ways to configure them for your apps

Key Features

  • Second edition updated and enhanced to cover the latest .NET 6 features and changes
  • Learn authentication and authorization techniques for securing your web apps from a .NET veteran
  • Discover best practices for configuring ASP.NET Core, from user interface design to hosting it on platforms

Book Description

ASP.NET Core is packed full of hidden features for building sophisticated web applications – but if you don’t know how to customize it, you’re not making the most of its capabilities. Customizing ASP.NET Core 6.0 is a book that will teach you all about tweaking the knobs at various layers and take experienced programmers’ skills to a new level.

This updated second edition covers the latest features and changes in the .NET 6 LTS version, along with new insights and customization techniques for important topics such as authentication and authorization. You’ll also learn how to work with caches and change the default behavior of ASP.NET Core apps.

This book will show you the essential concepts relating to tweaking the framework, such as configuration, dependency injection, routing, action filters, and more. As you progress, you'll be able to create custom solutions that meet the needs of your use case with ASP.NET Core. Later chapters will cover expert techniques and best practices for using the framework for your app development needs, from UI design to hosting. Finally, you'll focus on the new endpoint routing in ASP.NET Core to build custom endpoints and add third-party endpoints to your web apps for processing requests faster.

By the end of this book, you'll be able to customize ASP.NET Core to develop better, more robust apps.

What you will learn

  • Explore various application configurations and providers in ASP.NET Core 6
  • Enable and work with caches to improve the performance of your application
  • Understand dependency injection in .NET and learn how to add third-party DI containers
  • Discover the concept of middleware and write your middleware for ASP.NET Core apps
  • Create various API output formats in your API-driven projects
  • Get familiar with different hosting models for your ASP.NET Core app

Who this book is for

This book is for .NET developers who’ve already covered the basics and are now looking to learn more about changing default behaviors of the framework to help improve the performance of their applications. Intermediate-level knowledge of ASP.NET core and C# is a must before you get started; there’s no refresher and very little theory in this book.

Table of contents

  1. Customizing ASP.NET Core 6.0
  2. Second Edition
  3. Foreword
  4. Contributors
  5. About the author
  6. About the reviewer
  7. Preface
    1. ASP.NET Core architecture overview
    2. What is covered in this book?
    3. What is not covered and why?
    4. Who this book is for
    5. What this book covers
    6. To get the most out of this book
    7. Download the example code files
    8. Download the color images
    9. Conventions used
    10. Get in touch
    11. Share Your Thoughts
  8. Chapter 1: Customizing Logging
    1. Technical requirements
    2. Configuring logging
    3. Creating a custom logger
    4. Plugging in an existing third-party logger provider
    5. Summary
  9. Chapter 2: Customizing App Configuration
    1. Technical requirements
    2. Configuring the configuration
    3. Using typed configurations
    4. Configuration using INI files
    5. Configuration providers
    6. Summary
    7. Further reading
  10. Chapter 3: Customizing Dependency Injection
    1. Technical requirements
    2. Using a different DI container
    3. Exploring the ConfigureServices method
    4. Using a different ServiceProvider
    5. Introducing Scrutor
    6. Summary
  11. Chapter 4: Configuring and Customizing HTTPS with Kestrel
    1. Technical requirements
    2. Introducing Kestrel
    3. Setting up Kestrel
      1. For your safety
    4. Summary
  12. Chapter 5: Configuring WebHostBuilder
    1. Technical requirements
    2. Re-examining WebHostBuilderContext
      1. How does it work?
    3. Summary
    4. Further reading
  13. Chapter 6: Using Different Hosting Models
    1. Technical requirements
    2. Setting up WebHostBuilder
    3. Setting up Kestrel
    4. Setting up HTTP.sys
    5. Hosting on IIS
    6. Using Nginx or Apache on Linux
      1. Configuring Nginx
      2. Configuring Apache
    7. Summary
    8. Further reading
  14. Chapter 7: Using IHostedService and BackgroundService
    1. Technical requirements
    2. Introducing IHostedService
    3. Introducing BackgroundService
    4. Implementing the new Worker Service projects
    5. Summary
  15. Chapter 8: Writing Custom Middleware
    1. Technical requirements
    2. Introducing middleware
    3. Writing custom middleware
    4. Exploring the potential of middleware
      1. Branching the pipeline with /map
      2. Branching the pipeline with MapWhen()
      3. Creating conditions with middleware
    5. Using middleware in ASP.NET Core 3.0 and later
      1. Rewriting terminating middleware to meet the current standards
    6. Summary
  16. Chapter 9: Working with Endpoint Routing
    1. Technical requirements
    2. Exploring endpoint routing
    3. Creating custom endpoints
    4. Creating a more complex endpoint
    5. Summary
  17. Chapter 10: Customizing ASP.NET Core Identity
    1. Technical requirements
    2. Introducing ASP.NET Core Identity
    3. Customizing IdentityUser
    4. Customizing the Identity views
    5. Summary
  18. Chapter 11: Configuring Identity Management
    1. Technical requirements
    2. Introducing IdentityManager2
    3. Setting up IdentityManager2
    4. Securing IdentityManager2
    5. Summary
  19. Chapter 12: Content Negotiation Using a Custom OutputFormatter
    1. Technical requirements
    2. Introducing OutputFormatter objects
      1. Preparing a test project
    3. Testing the web API
    4. Creating custom OutputFormatter objects
    5. Summary
  20. Chapter 13: Managing Inputs with Custom ModelBinder
    1. Technical requirements
    2. Introducing ModelBinder
    3. Preparing the test data
    4. Preparing the test project
    5. Creating PersonsCsvBinder
    6. Using ModelBinder
    7. Testing ModelBinder
    8. Summary
    9. Further reading
  21. Chapter 14: Creating a Custom ActionFilter
    1. Technical requirements
    2. Introducing ActionFilter
    3. Using ActionFilter
    4. Summary
    5. Further reading
  22. Chapter 15: Working with Caches
    1. Technical requirements
    2. Why do we need caching?
    3. HTTP-based caching
    4. Caching using ResponseCachingMiddleware
      1. Predefining caching strategies using cache profiles
    5. Caching specific areas using CacheTagHelper
    6. Caching Manually
    7. Summary
    8. Further reading
  23. Chapter 16: Creating Custom TagHelper
    1. Technical requirements
    2. Introducing TagHelper
    3. Creating custom Tag Helpers
      1. Examining a more complex scenario
    4. Summary
    5. Further reading
    6. Why subscribe?
  24. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Customizing ASP.NET Core 6.0 - Second Edition
  • Author(s): Jürgen Gutsch
  • Release date: December 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781803233604