public class HomeController : Controller { public IActionResult Index() { return View(); } }
public class HomeController : Controller { public IActionResult Index() { ViewData["Message"] = "Hello World!"; return View(); } }
public class HomeController : Controller { public IActionResult Index() { return View(); } public IActionResult MyPartialView() { return PartialView("_MyPartialView"); } }In this example, we have a HomeController class with two methods - Index() and MyPartialView(). The Index() method returns the View and the MyPartialView() method returns the Partial View with the name "_MyPartialView". Package Library: Microsoft.AspNetCore.Mvc. PartialViewResult.