Web Server

W21 ASP.NET Core 1.0 Tag Helpers

03/15/2017

4:30pm - 5:45pm

Level: Intermediate

Robert Boedigheimer

Principal Systems Developer

Schwans Shared Services, LLC

ASP.NET Core 1.0 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." This 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 aren't available from a CDN. The "asp-append-version" automatically used on URLs 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, you can also 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