ASP.NET Monsters #70: Accessing View Context from Tag Helpers

Play ASP.NET Monsters #70: Accessing View Context from Tag Helpers

The Discussion

  • User profile image
    Ravi

    I am trying to figure out when to use a viewcomponent and when use a taghelper
    Just curious isn't it better to use a view viewcomponent in this scenario

  • User profile image
    ghandlin

    Trying to access ViewContext with the head attribute in a layout page. No love. Is there a way to get at it there?

  • User profile image
    ghandlin

    Actually found it, the naming appears to need to be convention based.

    This works:

    public class HeadTagHelper : TagHelper  

     

    This does not:

    [HtmlTargetElement("head")]
    public class MyTagHelper : TagHelper

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.