The end game of this series is to build scalable .NET applications with Clean Architecture! I am building the content one by one to reach to the finale - Practical Clean Architecture in ASP.NET Core!
Join the Series along with 5,000+ other .NET Developers! 🎉 - Subscribe
When building a new ASP.NET Core project, prioritizing the setup of logging is crucial for robust monitoring and debugging capabilities right from the start. Serilog is the most popular logging library for ASP.NET Core applications.
In this article, we will:
- Explore the importance of logging in ASP.NET Core projects.
- Learn everything you need to know to master structured logging using Serilog.
By the end of this tutorial, you will have a solid understanding of how to implement and utilize Serilog for effective structured logging in your ASP.NET Core application.
Exception handling is vital for applications of all types and traffic volumes. If exceptions are not managed well within the application, it can break the entire system or even lead to data loss. In ASP.NET Core, there are multiple ways to handle exceptions effectively.
In this article, we will discuss:
- Try-Catch Blocks
- Default Exception Handling Middleware
- Custom Exception Middleware
- IExceptionHandler
Starting from .NET 8, IExceptionHandler
is the recommended and cleaner approach for handling exceptions. This method ensures a more robust and maintainable exception handling strategy for your applications.
When it comes to validating models and incoming HTTP requests, many of us tend to lean toward using Data Annotations. Although setting up Data Annotations on your models can be quick and easy, there are a few drawbacks to this approach, especially for larger projects.
In this article, we will:
- Understand the problems with using Data Annotations in larger projects.
- Explore an alternative approach using FluentValidation in our ASP.NET Core application.
FluentValidation can elevate your validation process, giving you total control and enabling you to write much cleaner and more maintainable code.
CQRS (Command Query Responsibility Segregation) is a software architectural pattern that separates the read and write operations of a system into two distinct parts.
- Write Operations (Commands) and Read Operations (Queries) are handled separately.
- Different models are optimized for each type of operation.
This separation can lead to simpler and more scalable architectures, especially in complex systems where the read and write patterns differ significantly.
In this article, we will:
- Build an ASP.NET Core 8 Web API with CRUD functionalities.
- Implement the CQRS pattern.
- Use the MediatR library for managing commands and queries.
By the end of this tutorial, you'll have a deeper understanding of how to create clean, scalable .NET systems using CQRS.