Global Error Handling in ASP.NET Core Web API (updated video link in the description)

Code Maze
Code Maze
60.6 هزار بار بازدید - 4 سال پیش - ►► Master Web API development
►► Master Web API development Best Practices: https://bit.ly/3TnqoFQ
►► Build great web apps in Blazor WebAssembly: https://bit.ly/437g87T
►► Support us on Patreon and get the source code: Patreon: CodeMaze

UPDATED CONTENT (.NET 8): Global Exception Handling in ASP.NET ...

The exception-handling features help us deal with the unforeseen errors that could appear in our code. Let's learn how to implement it.

FOLLOW US ON SOCIAL MEDIA!
►► LinkedIn: marinko-spasojevic
►► Twitter: CodeMazeBlog
►► Facebook: CodeMazeBlog

VIDEO SUMMARY:
Even though there is nothing wrong with the try-catch blocks in our Actions in Web API project, we can extract all the exception-handling logic into a single centralized place.

By doing that, we make our actions more readable and the error-handling process more maintainable. If we want to make our actions even more readable and maintainable, we can implement Action Filters.

We won’t talk about action filters in this article but we strongly recommend reading our post Action Filters in .NET Core.

In this video, we are going to handle errors by using a try-catch block first and then rewrite our code by using built-in middleware and our custom middleware for global error handling to demonstrate the benefits of this approach.
4 سال پیش در تاریخ 1398/11/25 منتشر شده است.
60,617 بـار بازدید شده
... بیشتر