How to display a row from an action result

there is an action: / Home / GetName and returns the string "Mike", the controller and the action are like:

public class HomeController : Controller
{
    public string GetName()
    {
        return "Mike";
    }
}

How can I display this result of an action in a view? (without ajax is better)

+4
source share
1 answer

You can use ContentResultto return a string, for example

public ActionResult GetName() {
    return Content("Mike");
}

Note that by default, the text / plain type is returned ContentResult.

+8
source

Source: https://habr.com/ru/post/1624912/


All Articles