Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is difference between Actionresult and IActionresult?

What I have tried:

What is difference between Actionresult and IActionresult?
Posted
Updated 1-Apr-18 7:13am
v2

1 solution

Talking about ASP.NET Core ecosystem and how IActionResult has helped, is that IActionResult is an interface, and the platform is the one defining a type of a response — you can create a custom response, rather than just predefined ones for returning a View or a resource, here you can return a response, or error as well. On the other hand, ActionResult is an abstract class, and you would need to make a custom class that inherits and then further stuff. But, there is no limitation in any case, just a friendly way to tackle the programming.

And you can also do that by following the patterns used in ASP.NET Core. Returning HttpStatusCodeResult with different codes and returning Ok, NotFound etc., needs to be checked within the team to see which is better and which is not that much useful. How to return HTTP 500 from ASP.NET Core RC2 Web Api? - Stack Overflow[^]

Since this is an interface, you can create mock classes and types to test the application as well.

Read this thread on SO as well, asp.net core - Advantage of using IActionResult as result type in Actions - Stack Overflow[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900