Try our conversational search powered by Generative AI!

ContentReference and ID property with value zero


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.


The exception appers when I have ID = 0

May 20, 2018 18:54

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.

May 20, 2018 23:09
Jun 04, 2018 10:31

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.

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.