In the Asp.NET core's layout page, I'm trying to load the result of an AJAX post. Status is OK but comes as an error:
_Layout.cshtml
<div id="MainContentDiv">
@RenderBody()
</div>
$.ajax({
type: 'POST',
url: '/Something/LoadView',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({ ... }),
error: function (result) {
console.log("error");
console.log(result);
},
success: function (result) {
$("#MainContentDiv").html(result);
}
[HttpPost]
public ActionResult LoadView([FromBody] NodeData model)
{
string action= "Index";
switch(model.NodeType)
{
case StringConstants.something:
action = "GData";
break;
// ...
}
return RedirectToAction(action, "Some", model);
}
public PartialViewResult GData(NodeData model)
{
// ...
return PartialView("_GroupsData", group);
}
Response