ASP.NET Monsters #24: View Components in ASP.NET MVC Core

Play ASP.NET Monsters #24: View Components in ASP.NET MVC Core

The Discussion

  • User profile image

    Every time i see someone talk about view components I feel like the concept should be merged with taghelpers to some extent. They both can have services register in the DI container injected into them, they bot do some processing and output markup to the page. 

    The way things are today, what are the advantages of using TagHelpers in one instance or ViewComponents in another



  • User profile image

    @scyonx: Excellent question.

    One advantage of View Components is that you can define the View portion in Razor. With TagHelpers you are limited to generating HTML using C#.  

    An advantage of Tag Helpers is that the markup when using the tag helper is much cleaner (<my-tag-helper>) vs @Component.Invoke. As I showed towards the end of the video I do think this will change for view components eventually.

    TagHelpers also have a different use case given that you can target existing HTML elements. You can't do that with ViewComponents. 

  • User profile image

    That intro animation nearly burst my * eardrums!

Conversation locked

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