Q&A: Robert Boedigheimer on ASP.NET Core 1.0 Tag Helpers
Find out more about this new feature of ASP.NET Core 1.0 and how it might help you.
We recently asked him for a bit of a preview on the topic:
What would you say the top three benefits of using Tag Helpers?
First, you get a more HTML-like syntax than pre-existing HTML Helpers in Razor files. Second, there are many built-in Tag Helpers that simplify common tasks that many Web sites will encounter. Third, there is a server-side mechanism for creating custom reusable HTML elements or attributes to render HTML.
What are the top built-in tag helpers devs should know about?
- <environment> -- to include content only when on a particular level of server (development, stage, production).
- asp-append-version -- adds a version number to URLs to override caches and ensure the latest version is used.
- asp-fallback-href -- can specify a local file to use if a file doesn't properly download from a CDN.
What ways do you like to use Tag Helpers?
I like to use the built-in Tag Helpers where available. The ability to build custom Tag Helpers provides a great mechanism to provide reusable server-side functionality for a Web site. My session will review how to build custom Tag Helpers to utilize responsive images using the latest srcset attribute and <picture> tag.
Do Tag Helpers ever get in the way?
The nice thing is you don't have to use them if you don't want to, and you can selectively disable on particular elements.
What is the best thing that people will get out of attending your session?
An understanding of the built-in tag helpers and how to create your own.
Is there anything you wish we asked you that we didn't?
Yes, I really am a third-degree black belt in Tae Kwon Do, can break bricks and use nun-chucks, but won't be doing that for this session!