You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using ASP.NET core version 10.0.7 with API contrllers.
We're currently using the IActionResult interface 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 as NotFoundResult. However, for the TypedResult classes, the result type is HttpActionResult, 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 the Result property of the HttpActionResult, 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 HttpActionResult type be public instead of internal?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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