Reputation: 564
I have a fairly big view component that I want to use in two different asp.net core MVC projects. So far I found two approaches for accomplish this:
What are the trade-offs between these two approaches? My view component has nested view components and it requires java-script to implement some dynamic functionality.
Upvotes: 3
Views: 2378
Reputation: 4521
With ASP.NET Core 2.1 onwards you want to use Razor Class Libraries (RCL) which were designed for this very scenario.
RLC lets you create reusable UI with razor views, pages, controllers, page models, view components and data models. Added benefit is that views (even partial) are overridable by main app where the Razor markup (.cshtml file) takes precedence allowing for per-app changes without modifying the original shared component.
/MyFeature/Page1
Read the full documentation
Upvotes: 5