Copied to clipboard

Flag this post as spam?

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


  • Stephen Davidson 216 posts 392 karma points
    Oct 10, 2014 @ 16:42
    Stephen Davidson
    0

    Error: Object reference not set to an instance of an object. V 7

    I've seen this error elsewhere but the soltuion does not work for me.

    My v7 site has been working perfectly, i have the following code to render my home page banners.

     

    @inherits UmbracoTemplatePage
    
    @{
        var mediaFolderId = (int)CurrentPage.BannersMediaFolder;
    }
    
    @if (mediaFolderId > 0)
    {
        var mediaFolder = Umbraco.TypedMedia(mediaFolderId);
        var banners = mediaFolder.Children(x => x.DocumentTypeAlias == "Banner").ToList();
    
        
    @foreach (var banner in banners) { var link = Umbraco.TypedContent(banner.GetPropertyValue("link"));
    @if (link != null) { } else { }

    @(banner.GetPropertyValue("headline"))

    @(banner.GetPropertyValue("linktext"))

    @Html.Raw(banner.GetPropertyValue("subheadline"))

    }
    <script src="/scripts/jquery.carouFredSel-6.2.1-packed.js" type="text/javascript"><!--mce:0--></script>
    <script type="text/javascript"><!--mce:1--></script>
    }

    but now i get the Error: Object reference not set to an instance of an object. The only thing i have done is add another folder in my media folder...could this be connected?

  • Jan Skovgaard 11264 posts 23594 karma points MVP 9x admin c-trib
    Oct 11, 2014 @ 09:11
    Jan Skovgaard
    0

    Hi Stephen

    At a quick glance the above code seems allright to me and as you say it has been working.

    I'm wondering if the /App_Data/Logs file reveals some more information about the error?

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft