How to use View Components In ASP.NET Core 5.0 MVC?
View Components In ASP.NET Core 5.0 MVC The concept of ViewComponet in Asp.Net Core 5 MVC is very similar to a PartialView but it has more potential in it. ViewComponet renders a small chunk of view which is not a part of the controller or the HTTP life cycle. Typical usage Additonal product suggestions Extra navigation menu Recently added posts A Small notice that has to be rendered in every page Sidebar content How to create a ViewComponent? Derive a class from ViewComponent public class Options : ViewComponent { } C# Copy Decorate the class using [ViewComponent] attribute [ ViewComponent ( Name = "Options" ) ] public class Options : ViewComponent { public IViewComponentResult Invoke ( ) { return View ( ) ; } } C# Copy Name the class ViewComponent as subfix public class OptionsViewComponent : ViewComponent { public IViewComponentResult Invoke ( ) { return View ( ) ; } } C# Copy View search path The runti