ContentReference and ID property with value zero

Vote:
 

When does property ID from ContentReference return 0 (Zero)? 

I ask becuase sometimes I hava a exception when I execute this line, although I have object ContentReference.

contentLoader.Service.Get(cat.ContentLink);

The exception appers when I have ID = 0

#192592
May 20, 2018 18:54
Vote:
 

If you've had some deleted content that was linked to or a property hasn't been set you may get an Empty content reference. It's best practice when using any ContentReference to call ContentReference.IsNullOrEmpty first as a check to make sure it's not an empty reference as if you try to load it you'll get an error.

#192594
May 20, 2018 23:09
Vote:
 
#193707
Jun 04, 2018 10:31
Vote:
 

Either do that null check or use IContentLoader.TryGet(ContentReference contentLink, out TContentType content). TryGet has that ContentReference.IsNullOrEmpty check internally and returns false in that case and content is set to null.

#193732
Jun 04, 2018 14:55
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.