Closed sahin52 closed 2 years ago
Thanks for contacting us. We're not making any improvements in this area any more as this project is in maintenance mode. Only critical blocking issue with wide impact and security issues are considered.
For other people struggling for this: you can still return any object and create BadRequest in some cases or something with the help of HttpResponseException. Just look here: https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/action-results#other-return-types
IHttpActionResult interface currently does not support generic method, but sometimes we have to use it and specify the return type, in order to prevent any errors and understand the return type easily.
Here is an example:
The first line function is IHttpActionResult but we can give any return type. It doesn't give any error. By this method, we can return any Http result like Redirect, or BadRequest or Ok etc, but we can't know what Ok will return. Most of our api endpoints return an object, rather than other Http results. Second function specifies the return type but we can't return the other Http results unfortunately. Third function sprecifies return type and can return Http results but is not supported :(
Is there a problem with adding this? Can we add this functionality?