Where is @Html.Action in Asp.net Core?
I can see @Html.ActionLink but not a direct call to an Action as before.
Was it replaced by ViewComp
@Html.Action was replaced by ViewComponents. I dislike ViewComponents for multiple reasons.
However I am using alternative pattern to @Html.Action
First I create Action on controller that is returning partial view with a content that I want to display in page i.e.
[HttpGet]
public async Task GetFoo()
{
return PartialView("_Foo", new Foo());
}
Then I place div on page where the foo view should be loaded and include IIFE at the bottom of that page. I.e. code bellow will load GetFoo view and then insert that html to div with id foo-view.
You may also want to display spinner while view is beign fetched from server.