I need to load my ViewComponents at runtime by selecting it out of a select-control.
The problem I face is, that the ViewComponent returns the full HTML page and not only the PartialView I need.
Javascript:
$.get("/MyComponent/Invoke", (html) => { console.log(html);});
ViewComponent:
public class MyComponentViewComponent : ViewComponent
{
private LoadData LoadData { get; }
public FavoritenViewComponent(LoadData loadData)
{
LoadData = loadData;
}
public IViewComponentResult Invoke()
{
var data= LoadData.List(_viewContext);
return View(data);
}
}
Is there any possibility to just return the partial view that is defined in the Default.cshtml file of the ViewComponent?