View Component Example Simple Dashboards v17
- Your View Component should match the name of your C# class plus
ViewComponent.cs- For example:
BasicDashboard.cs=>BasicDashboardViewComponent.cs
- For example:
- Your View Component must inherit either:
DashboardViewComponentDashboardAsyncViewComponent
public class ExampleDashboardViewComponent : DashboardAsyncViewComponent{ public override Task<IViewComponentResult> InvokeAsync(DashboardViewModel model) { // Complex business logic var viewModel = await _service.CreateViewModel(model); // ... return View("~/Views/MyPath/MyView.cshtml", viewModel); }}