asp.net-mvc ActionResult ContentResult

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

public ActionResult Hello()
{
    // Returns a user-defined content type, in this case a string.
    return Content("hello world!");
}

Action methods typically return a result that is known as an action result. The ActionResult class is the base class for all action results. The ActionInvoker decide which type of action result to return based on the task that the action method is performing.

It is possible be explicit about what type to return, but generally it not necessary.

public ContentResult Hello()
{
    // Returns a user-defined content type, in this case a string.
    return Content("hello world!");
}

You can know more about it here: Asp.Net Mvc: ContentResult vs. string



Got any asp.net-mvc Question?