Replies: 1 comment
-
|
This is a brilliant architectural question that highlights a known gap in the transition from traditional API Controllers ( You hit the nail on the head: Here is a breakdown of why this happens, why making Why is this happening?When you return a
Because it's The SolutionsInstead of fighting the internal wrapper in an Option 1: Use
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi community,
I'm using ASP.NET core version 10.0.7 with API contrllers.
We're currently using the
IActionResultinterface as return type on our controller actions and would like to migrate to TypedResults, as this provides strong typing for responses AND automatically documents the response types in our OpenAPI specifications.With the old ActionResults i was able to create an IAsyncResultFilter and inspect the type of the result. This can be done quite easily by using pattern checking on the type
ObjectResult, or other derived types such asNotFoundResult. However, for the TypedResult classes, the result type isHttpActionResult, which is an ASP.NET core internal type. So for now, i don't have a way to access the (typed) result using this filter, other than using reflection to access theResultproperty of theHttpActionResult, but that doesn't feel like the way to do it.I could not find any documentation on other filters that are able to access the (typed) result, so am i missing something, or should the
HttpActionResulttype be public instead of internal?Beta Was this translation helpful? Give feedback.
All reactions