0 0
Read Time:6 Minute, 1 Second

Every year, a new version of dotnet, my preferred framework, is launched. I went through each preview version before the final release and, in no particular order, chose the 5 New ASP.NET Core Features in dotnet 8 You’ll Love this Year. Microsoft has already developed many preview versions of the upcoming version, which will be accessible in a few months. The goal of Microsoft engineers is to make ASPnet core the best web framework ever. They actively listen to us (the community) and work tirelessly to improve the framework.

I’ve been keeping track of every ASPnet core update preview release for dotnet 8, and as of the time I was writing this article, we were on preview 6. I’m excited about the new capabilities, and in this blog I’ll share my five picks for the future ASPnet core upgrades in DotNet 8.

Global Exception Handling

If you’re an experienced ASP.NET Core developer, you’ve probably already put in place measures to capture every exception, report them, respond to clients appropriately, and make sure no important data is exposed in production. To automate this procedure, numerous blog entries and nugget packages have been made available over time. Now, with DotNet 8, we can easily integrate it to ASPnet Core.

This is possible thanks to the “IExceptionHandler” type that was added in dotnet 8. ASPnet core already had an Exception handler middleware that was added in previous dotnet versions. But this interface makes it possible to inject some custom exception-handling logic behind the scenes.

You first need to implement this interface, for your exception-handling logic, you can implement as many as you can, and they will be executed by order of registration.

public interface IExceptionHandler
{
   ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken);
}

Then, register it as follow. Where “T” is the type of your Exception handler class.

IServiceCollection.AddExceptionHandler<T>

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Rate this post
error: Content is protected !!