Copied to clipboard

Flag this post as spam?

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


  • Marco Graziotti 40 posts 166 karma points c-trib
    Oct 07, 2021 @ 11:10
    Marco Graziotti
    0

    "savedEntity.CultureInfos.Values" is null if a Document Type has "Allow vary by culture" set to false

    Hi,

    I have just updated Umbraco to the v. 9.0.1 and I'm facing a different behavior when I'm trying to check CultureInfos property in a "Component" that extend INotificationHandler<ContentSavingNotification>.

    When I try to get the values from "CultureInfos", if the saved Document Type has the Allow vary by culture set to false (turned off), I get a null value.

    Before the update to the v.9 stable, with the Umbraco v. 9.0.0-beta002 the "CultureInfos" worked fine, returning at least one element, that is the default language.

    Do you have any suggestions? Is that a bug?

    Here the code snippet:

    public class WhenAPageIsPublishedComponent : INotificationHandler<ContentSavingNotification>
    {
        private readonly IConfiguration configuration;
    
        public WhenAPageIsPublishedComponent(IHttpContextAccessor contextAccessor, IConfiguration configuration)
        {
            ...
        }
    
        public void Handle(ContentSavingNotification notification)
        {
            foreach (IContent savedEntity in notification.SavedEntities)
            {
                string name = savedEntity.CultureInfos.Values.FirstOrDefault().Name;
    
                ...
            }
        }
    

    Thank you

  • Marco Graziotti 40 posts 166 karma points c-trib
    Oct 11, 2021 @ 11:01
    Marco Graziotti
    0
Please Sign in or register to post replies

Write your reply to:

Draft