When inheriting from base Controller class provided by the framework, you can use the convenience method ViewComponent() to return a view component from the action:
public IActionResult GetMyComponent()
{
return ViewComponent("Login", new { param1 = "foo", param2 = 42 });
}
If using a POCO class as a controller, you can manually create an instance of the ViewComponentResult class. This would be equivalent to the code above:
public IActionResult GetMyComponent()
{
return new ViewComponentResult
{
ViewComponentName = "Login",
Arguments = new { param1 = "foo", param2 = 42 }
};
}