Tuesday, August 17, 2021

.NET 6 Preview 7: Introducing Static Results Utility Class for Producing Common HTTP Responses as IResult Implementations

Last week .NET 6 Preview 7 was released and one of the new features that got introduced to the world of ASP.NET Core is a new static Results utility class to produce common HTTP responses as IResults. IResult is a new return type that got introduced with Minimal APIs. 

If you are new to Minimal APIs in ASP.NET Core or need to refresh your memories, you can read these posts.

Previously we had to use/maintain our own class to Map IActionResult to IResult.  With this new Results utility class, we no longer have to do that.

If you explore the Results class, it has IResult types for almost all the regularly used HTTP responses.
IResult
You can find the sample code here,
      (PR for Updating packages to .NET Preview 7 and introduce use of static Results utility class)

Hope this helps.

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment