public IActionResult GetPartialView()
{
return PartialView("_PartialViewName");
}
$.ajax({
type: "GET",
url: "@Url.Action("GetPartialView", "ControllerName")",
success: function(response) {
$("body").html(response);
}
});
其中"_PartialViewName"是你要渲染的视图名称,"ControllerName"是你的控制器名称。
@ViewData["Title"]
@RenderSection("Styles", required: false)
@RenderBody()
@RenderSection("Scripts", required: false)
这样就可以在Body部分中显示你的部分视图了。