Copied to clipboard

Flag this post as spam?

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


  • Johanna Dunn 6 posts 76 karma points
    Mar 28, 2016 @ 19:39
    Johanna Dunn
    0

    Error if tags are empty

    Hi, I'm using SmartBlog 2.2.1 on Umbraco 7.4.2 and if any of the articles don't have tags, then when i click on the tag link on the side menu I get the error below. If I add tags to all articles then there is no error.

    Is there anyway to prevent the error if not all pages have tags? I tried this on a fresh install of Umbraco with nothing else on it, as well as the site I'm currently building, and got the same error.

    Thanks

    Object reference not set to an instance of an object.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 31:
    if (!String.IsNullOrEmpty(Request.QueryString["tag"])) { colResults = colResults.Where(x => x.GetPropertyValue

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 31, 2016 @ 22:04
    Alex Skrypnyk
    0

    Hi Johanna,

    Try to rewrite your code snippet:

    if (!String.IsNullOrEmpty(Request.QueryString["tag"])) { colResults = colResults.Where(x => x.GetPropertyValue("smartBlogTags") != null && x.GetPropertyValue("smartBlogTags").Split(',').Contains(Request.QueryString["tag"])); }
    

    Please add checking for null on x.GetPropertyValue("smartBlogTags")

    Cheers, Alex

Please Sign in or register to post replies

Write your reply to:

Draft