Is it recommended to define specific return types for controller actions?
Or in other words since results like JSONRESULT, VIEWRESULT
etc... derive from ACTIONRESULT
what is the best practice in terms of specifying the return type for a controller action.
ACTIONRESULT
or a more specific Result type.
Is there any best practice/OOAD aspect approach to this.
I don't think there is a specific recommendation for that. My opinion today (I used to be more specific) is the same as Dan, because I find it easier to maintain my code that way.
The best practise is always that to keep our method's parameters and return types the most generic types like we accept IEnumerable not an T[] and this is true for return types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With