Handle ASP.NET Core Exceptions Globally

preview_player
Показать описание
Heyo! I'm Michael and in this video I’m going to talk about 3 ways to globally handle ASP.NET Core exceptions using the .UseExceptionHandler built-in middleware, writing custom middleware, and the new with .NET 8, IExceptionHandler interface. Plus a bonus on how to have multiple exception handlers.

Don't forget to comment, like and subscribe 🚀

💬 JOIN US ON DISCORD

🧑‍💻 LET'S CONNECT ON SOCIAL

#csharp #dotnet
Рекомендации по теме
Комментарии
Автор

Does your team handle ASP.NET Core exceptions globally or are you throwing try/catches everywhere? Got a horror story about weird exceptions? Let me know below. I love hearing these development war stories.

BaldBeardedBuilder
Автор

Greate video, really liking the new "watch as I code this" format. Seems more natural.

SpiderJack
Автор

Thanks for the quick demo + explanation! Keep it up!

Jason-yrfy
Автор

Great video. Love it. One way to mitigate the head issue is to have a github with the example code.

wusswuzz
Автор

"Why is it magic? Because it just is." :D Love it!

irawsum
Автор

Will this "global exceptions" work in.. Repository CRUD methods and in any network i/o C# code like file upload/download or any outside api calls.. ???

AslamNazeerShaikh
Автор

Thanks for the info and for the jokes 😂

aleksandrabershatska
Автор

plz make your head a bit smaller next time, then I can watch your code carefully 😂

williamliu
Автор

Finally found a great channel with training videos! 👍

feelingfun
Автор

What it you use mvc and web api in the same project

galberts
Автор

Great video, only thing I don't like, architecturally, is the status code in the exception. The data or business layers shouldn't be bound to run in a http context. The status code should be determined in the exception handler according to the exception (base class, extending an interface, properties or whatever fits best)

taconaut
Автор

This doesnt feel right. Why does your service throw exceptions tied to http status codes when your service might not be exposed via HTTP?
What if I throw my service into an azure function or desktop application. It doesnt make sense to tie a network application layer into your code. This is why we have model validation before any user service is hit so we can separate out 4xx bad user requests and 5xx application errors.

KieranDevvs
Автор

I don't think user input should cause exceptions should they? If it does I'd let them to surface so you can fix them.

svorskemattias
Автор

I like it, but why return an exception when we know that it is an exception, it is better to return by result

anonim
Автор

Great job! But you are too big in the video. Can you make yourself smaller?

ИванИванов-яэк
Автор

Your head is unnecessary man. I do prefer the only code video
Thanks for the video tho. Keep it ip

bswill