Skip to content

VariationContext is modified when calling .Url() function on IPublishedContent #20718

@jopperuessink-frontis

Description

@jopperuessink-frontis

Which Umbraco version are you using?

v16

Bug summary

In my project, I have a piece of code responsible for building a language switcher. To generate this language switcher, I loop through all available languages and call the IPublishedContent.Url(culture: <culture>) function for each one. This allows me to retrieve the URL in the corresponding language so that the language switcher can display all available URLs per language.

What I’ve noticed, however, is that the .Url() function occasionally modifies the VariationContext to the specified culture. I assume this is unintended behavior, as the function is expected to be a getter rather than a modifier.

Specifics

No response

Steps to reproduce

  • Create a template (.cshtml)
  • Use the ILanguageService to loop through all available languages.
  • On the IPublishedContent of the current page, call the .Url(culture) function.
  • Observe that, sporadically, the culture is changed to a different language after the loop has finished executing.

Expected result / actual result

Expected:

  • The user’s language should not be changed by calling the .Url() function, and the entire page should be rendered in the same language.

Actual:

  • The user’s language (VariationContext) is modified when using the .Url() function.
  • The page is rendered in multiple languages.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions