Web Server

VSH05 ASP.NET Tag Helpers


9:30am - 10:45am

Level: Intermediate

Robert Boedigheimer

Principal Systems Developer

Schwans Shared Services, LLC

ASP.NET has introduced Tag Helpers which are a much more HTML-centric approach to using server-side code to help construct HTML elements in Razor views. ASP.NET will ship with built in tag helpers such as the "environment" that can include specific HTML (such as links to CSS or script tags) based on the level of server like development, stage, or production. Tag helpers provide specific attributes for elements like the "asp-fallback" attributes for automatic fallback to local resources when they are not available from a CDN. The "asp-append-version" used on URLs automatically appends a hash of the file contents to allow aggressive use of expirations for caching while forcing server requests when the files are modified. Besides the many tag helpers provided directly by ASP.NET, it is also possible to use third party tag helpers or create your own! This session will review a custom tag helper used to augment the lowly "img" tag to provide simple support for responsive images that delivers the most appropriate image for a particular device and use.

You will learn:

  • How to use built in tag helpers for downloading specific JavaScript and CSS
  • Compare Tag Helpers with existing HTML Helpers
  • How to create custom tag helpers