Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Keith 74 posts 240 karma points
    Jun 02, 2021 @ 09:15

    TagQuery marked as Obsolete on UmbracoHelper, but how do you use the alternative?

    Hi Everyone,

    I am trying to query a group of tags from a razor view. I can see from various discussions that the suggested approach for this used to be:


    But "TagQuery" has been marked as obsolete in the V8 code and removed in the V9 code. It says:

    "Inject and use an instance of ITagQuery in the constructor for using it in classes or get it from Current.TagQuery in views."

    But how do I use "Current.TagQuery" in my razor view? Because "Current" is not a property on the UmbracoHelper. So I cant just do:


    I have tried including:

    @using Umbraco.Web.Composing

    Because, this is where the "Current" class exists in the code. But I get an error:

    "The type or namespace name 'Web' does not exist in the namespace 'Umbraco'"

    Can anyone advise how this is supposed to work?



  • Bjarke Berg 29 posts 265 karma points hq
    Jun 02, 2021 @ 09:19
    Bjarke Berg


    In views you can use the @inject keyword..

    @using Umbraco.Cms.Core.PublishedCache;
    @inject ITagQuery TagQuery;
  • Keith 74 posts 240 karma points
    Jun 02, 2021 @ 09:41

    Wow! Thanks

  • Anders Jensen 5 posts 75 karma points
    Oct 29, 2021 @ 08:19
    Anders Jensen

    Hi, have any one tried the GetContentByTag("Test", "Group1") ? Is there a known bug ?

    I get 0 Content back, but I get all if I use the GetAllTags().

    Im testing out Umbraco 9

    EDIT: Found the issue, the tag name has to be lowercase to work.....

  • Angel 51 posts 108 karma points
    Sep 14, 2022 @ 14:57

    Hi, I am using Umbraco v8

    I am trying to use ITagQuery in a partial view for building out a block view.

    I tried to add the following : @inherits UmbracoViewPage

    the first issue is: Cms does not exist in the namespace Umbraco the second issue is: The name 'inject' does not exist in the current context

    What am I missing or doing wrong?

Please Sign in or register to post replies

Write your reply to: