Reading the latest documentation for ASP.Net Core 3.1, it is now recommended to use Razor Components over View Components. From 1,000 feet, this looks like a great idea as there is a single-file now instead of a "controller" and a default "view". More precise, compact, and I am assuming more efficient.
One big of information that took me by surprise, was the fact that tag helpers aren't supported in Razor Components (reference):
Tag Helpers aren't supported in Razor components (.razor files). To provide Tag Helper-like functionality in Blazor, create a component with the same functionality as the Tag Helper and use the component instead.
Am I the only one in all of the .NET world that thinks this is absolutely not acceptable? In view components, tag helpers are supported and are the single-most useful bits of .NET MVC. A simple example is the anchor tag helper. That is the most useful helper in my opinion as it accepts area
, controller
, action
, and a dynamic parameter list that generates an anchor tag without you having to worry about figuring out the routing.
Enough griping, to turn this into a question, how would one do this now in a Razor Component? The example on Microsoft's documentation for the tag helper is the ability to create a navigational menu using the tag helpers in a view component. Now, on the view component page, it is recommended to use Razor Components over View Components (reference):
When considering if view components meet an app's specifications, consider using Razor Components instead. Razor Components also combine markup with C# code to produce reusable UI units. Razor Components are designed for developer productivity when providing client-side UI logic and composition.
So, if one were to create a navigational menu in ASP.NET Core 3.1 (MVC) using Razor Components, what would be the easiest way to accomplish this without having to document every single route in Startup?