This is probably something simple. I've been away for a week and maybe my brain just hasn't caught up yet.
I'm unable to replicate the issue locally. But application insights is reporting a null reference exception on a check for if a thumbnail has a value.
foreach (var result in SearchResults)
{
IPublishedContent relatedArticle = Umbraco.TypedContent(result.Id);
if (result.Id != Umbraco.AssignedContentItem.Id && relatedArticle.HasValue("thumbnail"))
{
Its the last line in the above code.
Basically I'm running through some search results and i only want to display results that have a thumbnail. a lot of our legacy articles from years ago dont have a value.
Null Reference Exception
Hey.
This is probably something simple. I've been away for a week and maybe my brain just hasn't caught up yet. I'm unable to replicate the issue locally. But application insights is reporting a null reference exception on a check for if a thumbnail has a value.
Its the last line in the above code.
Basically I'm running through some search results and i only want to display results that have a thumbnail. a lot of our legacy articles from years ago dont have a value.
can anyone point me in the right direction?
Hi Dave
Add check for null like that:
Alex
This seems to have worked.
Would you be able to explain how it's possible for an article to appear in the search results if it doesnt even exist?
My search query already negates hidden and unpublished results from being retrieved.
Search results from Examine? How do you do the search?
It looks like nodes that make exception are deleted.
Thanks,
Alex
is working on a reply...