Applying standards to UIs
ASP.NET’s web page model has evolved over the years. With Web Forms, it was ViewState
and components. With MVC, it had partials and HTML Helpers. Now, ASP.NET 8 provides more advanced techniques using ViewComponent
classes and TagHelper
classes.
For this section, we’ll examine how ASP.NET 8 uses its language-specific features to build quicker and more flexible UIs. We’ll see how to consolidate links across a site, why it’s important to keep controllers/pages small, how ViewComponent
classes are better than partials and HTMLHelper
classes, and look at how to create SEO-friendly routes.
Centralizing your site links
If we have a large site with hundreds of links, developers understand what it means when a page is renamed, moved, or (gasp) deleted. It’s definitely a time-consuming effort to change every link on a large site. While TagHelper
classes are…well, helpful, one common practice is to use UrlHelper
classes...