System.InvalidOperationException: A view component named 'Filterlist' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.
Be sure do not put the ViewComponent class like below which locates inside DataController:
public class DataController : Controller
{
public IActionResult Filter()
{
return View();
}
public class FilterlistViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(string text)
{
var result = text;
return View(result);
}
}
}
You need put it outside the controller class and it can be located in any other folder.
For example:

Besides, in InvokeAsync
method, you return view with result
and the result
match the view name not the view model data. So when you pass new { text = "test" }
to ViewComponent, you will return test view, that is to say you need change Default.cshtml
to test.cshtml
or just add a new view test.cshtml
in your Data/Components/Filterlist
.