In this article I will explain with an example, how to use ContentResult in .Net Core.
ContentResult return type is used for returning Content i.e. String, XML string, etc. from Controller to View in ASP.Net Core MVC.
Note: For beginners in ASP.Net MVC Core, please refer my article ASP.Net MVC Core Hello World Tutorial with Sample Program example.
 
 
Controller
The Controller consists of the following Action method.
Action method for handling GET operation
Inside this Action method, the string message is sent to the Client using Content function.
Note: The Content function sends the data to the Response similar to Response.Write function.
 
public class HomeController : Controller
{
    public ContentResult Index(ControllerContext context)
    {
        return Content("Hello MVC Core!");
    }
}
 
 
Screenshot
ContentResult .Net Core Example: Using ContentResult in ASP.Net Core MVC
 
 
Downloads