Enterprise Application Development with C# 10 and .NET 6 - Second Edition

Book description

A comprehensive guide to every important component of C# and .NET 6 required to build robust enterprise web applications

Key Features

  • Explore the advanced features of C# and .NET 6 to enhance your code and productivity
  • Follow clear and easy instructions for building an end-to-end enterprise application
  • Learn how to build scalable web applications and host them on the cloud

Book Description

Building production-ready enterprise applications can be a challenging task due to the overabundance of tools and their different versions that make app development complex. This book simplifies the process with an end-to-end road map for building enterprise applications from scratch using the latest features of .NET Core 6 and C# 10.

Throughout the book, you'll work on creating an enterprise app, adding a key component to the app with each chapter, before finally getting it ready for testing and deployment. You'll learn concepts relating to advanced data structures, the Entity Framework Core, parallel programming, and dependency injection. As you progress, you'll cover various authentication and authorization schemes provided by .NET Core to make your apps and APIs secure. The book then shows you how the latest Microsoft Visual Studio and C# 10 help you simplify developer tasks and shares tips and tricks in Visual Studio to improve your productivity. You'll discover various testing techniques, such as unit testing and performance testing, as well as different methods to deploy enterprise apps.

By the end of this book, you'll be able to create enterprise apps using the powerful features of .NET 6 and deploy them to the cloud while working with various cloud components using Azure.

What you will learn

  • Design enterprise apps by making the most of the latest features of .NET 6
  • Discover different layers of an app, such as the data layer, API layer, and web layer
  • Explore end-to-end architecture by implementing an enterprise web app using .NET and C# 10 and deploying it on Azure
  • Focus on the core concepts of web application development and implement them in .NET 6
  • Integrate the new .NET 6 health and performance check APIs into your app
  • Explore MAUI and build an application targeting multiple platforms - Android, iOS, and Windows

Who this book is for

If you are a developer, architect, or senior programmer, this book will show you how to leverage the features of .NET 6 and the C# language, as well as help you grasp essential techniques to build your skills.

Table of contents

  1. Ravindra Akella
  2. Arun Kumar Tamirisa
  3. Suneel Kumar Kunani
  4. Bhupesh Guptha Muthiyalu
  5. Enterprise Application Development with C# 10 and .NET 6 Second Edition
  6. Contributors
  7. About the authors
  8. About the reviewer
  9. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  10. Part 1: Fundamentals
  11. Chapter 1: Designing and Architecting the Enterprise Application
    1. A primer on common design principles and patterns
      1. Design principles
      2. Design patterns
    2. Understanding common enterprise architectures
      1. Common issues with monolithic apps
      2. Let's try to solve these common problems by adopting some proven principles/ architectures.
      3. Separation of concerns/single-responsibility architecture
      4. Stateless services architecture
      5. Event-driven architecture
      6. Resiliency architecture
    3. Identifying enterprise application requirements (business and technical)
      1. The application's business requirements
      2. The application's technical requirements
    4. Architecting an enterprise application
    5. Solution structuring of the application
    6. Summary
    7. Questions
  12. Chapter 2: Introducing .NET 6 Core and Standard
    1. Technical requirements
    2. Introducing .NET 6
      1. Understanding the core features
      2. Understanding application frameworks
    3. Understanding the core components of .NET
    4. Setting up the development environment
    5. Understanding the CLI
      1. Overview of global.json
    6. What is .NET Standard?
      1. Understanding the use of .NET 6 and .NET Standard
    7. Understanding .NET 6 cross-platform and cloud application support
      1. Cloud support
    8. Summary
    9. Questions
    10. Further reading
  13. Chapter 3: Introducing C# 10
    1. Technical requirements
    2. Simplification of the using directives
      1. The global using directives
      2. The implicit using directives
    3. The record structs
    4. Improvements to Lambda expressions
      1. Inferring the expression type
      2. Return types for Lambda expressions
      3. Adding attributes to Lambda expressions
    5. Enhancements to interpolated strings
    6. Extended property patterns
    7. Addition to the caller argument attributes
    8. Summary
    9. Questions
  14. Part 2: Cross-Cutting Concerns
  15. Chapter 4: Threading and Asynchronous Operations
    1. Technical requirements
    2. Understanding the jargon
    3. Demystifying threads, lazy initialization, and ThreadPool
      1. Working with System.Threading.Thread
      2. ThreadPool
      3. Lazy initialization
    4. Understanding locks, semaphores, and SemaphoreSlim
      1. The critical section and thread safety
      2. Introducing locks
      3. Mutex (Windows only)
      4. Introducing semaphores and SemaphoreSlim
      5. Choosing the right synchronization constructs
    5. Introducing tasks and parallels
      1. Introduction to Task and the TPL
      2. Handling task exceptions
      3. Implementing task cancellation
      4. Implementing continuations
      5. SynchronizationContext
      6. TaskScheduler
      7. Implementing data parallelism
      8. Using Parallel LINQ (PLINQ)
    6. Introducing async-await
      1. The task-based asynchronous pattern
      2. Principles of using async-await
      3. Async streams with IAsyncEnumerable
      4. ThreadPool starvation
    7. Using concurrent collections for parallelism
      1. ConcurrentDictionary
      2. Producer-consumer concurrent collections
      3. The BlockingCollection<T> class
    8. Summary
    9. Questions
    10. Further reading
  16. Chapter 5: Dependency Injection in .NET 6
    1. Technical requirements
    2. What is DI?
      1. Types of DI
    3. DI in ASP.NET Core 6
      1. Understanding service lifetimes
      2. Managing application services
      3. DI in Razor Pages
    4. Using third-party containers
    5. Summary
    6. Questions
  17. Chapter 6: Configuration in .NET 6
    1. Technical requirements
    2. Understanding configuration
      1. Default configuration
      2. Adding configurations
      3. Reading configurations
    3. Leveraging built-in configuration providers
      1. Azure Key Vault configuration provider
      2. File configuration provider
    4. Building a custom configuration provider
      1. Configuration source
      2. Configuration provider
      3. Configuration extension
    5. Summary
    6. Questions
    7. Further reading
  18. Chapter 7: Logging in .NET 6
    1. Technical requirements
    2. Characteristics of good logging
    3. Understanding the available logging providers
      1. Built-in logging providers
      2. Third-party logging providers
    4. Working with Azure App Service
      1. Enabling application logging in Azure App Service
      2. Monitoring using metrics
    5. Real-time telemetry in Azure Application Insights
      1. Enabling application logging in Application Insights
    6. Creating a .NET 6 logging class library
    7. Summary
    8. Questions
  19. Chapter 8: All You Need to Know about Caching
    1. Technical requirements
    2. Introduction to caching
      1. Client caching
      2. Content Delivery Network (CDN)
      3. Web server caching
      4. Database caching
      5. Application caching
    3. Understanding the components of caching
      1. Response caching
      2. Distributed caching
      3. Cache access patterns
    4. Caching platforms
      1. In-memory cache
      2. Distributed cache
    5. Designing a cache abstraction layer using distributed caching
      1. Caching considerations
    6. Summary
    7. Questions
    8. Further reading
  20. Part 3: Developing Enterprise Applications
  21. Chapter 9: Working with Data in .NET 6
    1. Technical requirements
    2. Introduction to data
      1. Relational database management system (RDBMS)
      2. NoSQL
    3. SQL, Azure Cosmos DB, and Azure Storage
      1. SQL Server
      2. Azure Cosmos DB
      3. Azure Storage
    4. Working with EF Core
      1. Configuration and querying
      2. Code first versus database first
    5. Designing a Data Access service using Azure Cosmos DB
    6. Summary
    7. Questions
    8. Further reading
  22. Chapter 10: Creating an ASP.NET Core 6 Web API
    1. Technical requirements
    2. Introduction to REST
      1. The REST maturity model
    3. Understanding the internals of an ASP.NET Core 6 web API
      1. The Program class
      2. Understanding middleware
    4. Handling requests using controllers and actions
      1. Understanding ASP.NET Core routing
      2. Attribute-based routing
      3. The ControllerBase class, the ApiController attribute, and the ActionResult class
    5. Integration with the data layer
      1. Creating DTOs
      2. Service-class contracts
      3. The mapper class using AutoMapper
      4. HttpClient factory for service-to-service calls
      5. Implementing service classes
      6. Implementing action methods in the controller
    6. Understanding gRPC
      1. Building a gRPC server in .NET
      2. Building a gRPC client in .NET
      3. Testing gRPC services
    7. Summary
    8. Questions
    9. Further reading
  23. Chapter 11: Creating an ASP.NET Core 6 Web Application
    1. Technical requirements
    2. Introduction to frontend web development
      1. Razor syntax
      2. Exploring Razor Pages
      3. Exploring the ASP.NET Core MVC website
    3. Integrating APIs with the service layer
    4. Creating the controller and actions
    5. Creating a UI using ASP.NET Core MVC
      1. Setting up AdminLTE, the layout page, and views
    6. Understanding Blazor
    7. Summary
    8. Questions
    9. Further reading
  24. Part 4: Security
  25. Chapter 12: Understanding Authentication
    1. Technical requirements
    2. Understanding the elements of authentication in .NET 6
    3. Introduction to ASP.NET Core Identity
      1. Sample implementation
      2. Scaffolding
      3. Integration with external login providers
    4. Understanding OAuth 2.0
      1. Tokens
      2. Authorization grant types
    5. Introduction to Azure AD
      1. The Azure AD B2C setup
      2. Integrating our e-commerce application with Azure AD B2C
    6. Introduction to Windows Authentication
    7. Understanding best practices to secure client and server applications
    8. Summary
    9. Questions
    10. Further reading
  26. Chapter 13: Implementing Authorization in .NET 6
    1. Technical requirements
    2. Back to a few basics
    3. Understanding authorization
      1. Simple authorization
      2. Enabling authorization globally
    4. Role-based authorization
      1. Policy-based role authorization
      2. Implementing role-based authorization
    5. Claims-based authorization
    6. Policy-based authorization
      1. Requirements
      2. Requirement handlers
      3. Registering a policy
    7. Custom authorization
      1. Custom authorization attributes
    8. Authorization in client and server applications
      1. Assigning roles to users
      2. User identity in views
    9. Summary
    10. Questions
    11. Further reading
  27. Part 5: Health Checks, Unit Testing, Deployment, and Diagnostics
  28. Chapter 14: Health and Diagnostics
    1. Technical requirements
    2. Introducing health checks
    3. The health check API in ASP.NET Core 6
      1. Adding a health check endpoint
      2. Monitoring dependent URIs
      3. Building a custom health check
    4. Monitoring the application with Application Insights
      1. Live Metrics
      2. Usage analysis with Application Insights
      3. Smart Detection
      4. Application availability
      5. Search
      6. Logs
    5. Configuring the Snapshot Debugger
    6. Performing remote debugging
    7. Summary
    8. Questions
    9. Further reading
  29. Chapter 15: Testing
    1. Technical requirements
    2. Introducing testing
    3. Unit testing
      1. Unit testing in Visual Studio
      2. Code coverage
    4. Functional testing
      1. Automating functional test cases
    5. Load testing
      1. Load testing with JMeter
    6. Summary
    7. Questions
  30. Chapter 16: Deploying the Application in Azure
    1. Technical requirements
    2. Introducing Azure DevOps
      1. Boards
      2. Repos
      3. Pipelines
      4. Test Plans
      5. Artifacts
    3. Understanding the CI pipeline
      1. Understanding the flow and components of a pipeline
    4. Understanding the CD pipeline
      1. Continuous deployment versus CD
    5. Deploying an ASP.NET 6 application
      1. Creating a pipeline for CI and CD
    6. Summary
    7. Questions
    8. Further reading
    9. Why subscribe?
  31. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Enterprise Application Development with C# 10 and .NET 6 - Second Edition
  • Author(s): Ravindra Akella, Arun Kumar Tamirisa, Suneel Kumar Kunani, Bhupesh Guptha Muthiyalu
  • Release date: June 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803232973