Unable to access related media in other environments - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Unable to access related media in other environments

  • Unable to access related media in other environments
  • I have the following code which works fine for getting the media URL of a single image field on my local machine, but when I move the code to our staging environment and create new content, it acts like there is no related image (GetValue returns null):

     

                var model = new SportsNewsModel NewsItems = new List<SportsNewsItem>() ;
                var topNews = GetDynamicContentItems("Telerik.Sitefinity.DynamicTypes.Model.ClackamasNews.Article")
                    .Where(i => i.FieldValue<string[]>("Categories").Contains("2"))
                    .OrderByDescending(i => i.GetValue<DateTime?>("ArticleDate"))
                    .Take(2);

                foreach (var i in topNews)
               
                    var sportsNewsItem = new SportsNewsItem();
                    var imageField = i.GetValue<Image>("ArticleImage");

                    sportsNewsItem.Headline = i.GetString("Title").ToString();
                    sportsNewsItem.NewsPath = i.ItemDefaultUrl;
                    sportsNewsItem.PublishDate = i.GetValue<DateTime?>("ArticleDate").Value;
                    sportsNewsItem.ImagePath = imageField != null ? imageField.MediaUrl : string.Empty;

                    model.NewsItems.Add(sportsNewsItem);
               

                return View("Default", model);