We have moved to GitHub Issues
Created by Matt Brailsford 07 Dec 2012, 14:27:09 Updated by Shannon Deminick 24 Oct 2016, 07:44:51
Relates to: U4-2045
When calling TypedContent helper method and passing it an ID of an item in the recycle bin, a YSOD is thrown saying DynamicNULL can't be converted to IPublishedContent. I check needs to be added to the private TypedDocumentById to ensure the return value from DocumentById is not DynamicNull, and if it is, return null.
I'm not sure if there should be another helper that maybe doesn't return null at all (ie, if it doesn't exist or is in the bin, don't return anything).
PS I've classified this as major because currently there is no way round it. If the node is in the bin, it YSODs so it's not possible to capture in a nice way. You could do a try catch, but it would mean whatever you are rendering, the whole thing would not display.
I can confirm this happens - when calling
var node = @Umbraco.TypedContent(id);
if the id doesn't match a node that exists, throws the exception:
"Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to 'Umbraco.Core.Models.IPublishedContent'. An explicit conversion exists (are you missing a cast?)"
Would expect it to return a null so that can be checked to see if the node exists or not?
I've just been bitten by this as well in 4.11.5 (not update to 4.11.6 quite yet). It would be good to see this fixed in the 4.11 branch. Should this not be marked as open, rather than fixed?
I still got this in version 7.. it says it fixed ?
@saadan if you have steps to replicate, please open a new issue - once issues are closed they cannot be re-opened.
Assignee: Shannon Deminick
Backwards Compatible: False
Affected versions: 4.10.0, 4.11.0, 4.11.1
Due in version: 6.0.0