ASP.NET when to use IActionResult and when to use IResult?

Advertisements

I am trying to understand what the pros and cons are of IActionResult and IResult as return types and when to use the approopriate one. From what i’ve gathered IActionResult is just like IResult but with more options on how to handle the result?

>Solution :

IActionResult :: Defines a contract that represents the result of an action method.ASP.NET Core 7

IActionResult allows you to provide some more operations based on your actions like redirecting, changing the response’s format etc.

Use IActionResult on the side of your web application – MVC, since it gives you more approaches to handle requests.

IResult :: Defines a contract that represents the result of an HTTP endpoint. ASP.NET Core 7

Leave a ReplyCancel reply