Copied to clipboard

Flag this post as spam?

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


  • Barry Fogarty 493 posts 1129 karma points
    Nov 23, 2015 @ 06:21
    Barry Fogarty
    0

    Pass Detached product content to controller action

    I'd like to pass a single item from a nested content list to a controller action, however this results in the following exception:

    Type 'Umbraco.Core.Models.PublishedItemType' with data contract name 'PublishedItemType:http://schemas.datacontract.org/2004/07/Umbraco.Core.Models' is not expected.

    I have tried using IPublishedContent and RenderModel as the parameter of my action. I can see the object type being passed is DetachedProductContent (presumably implementing IPublishedContent?) but I cannot use this in my controller - presumably as its not public.

    Is this possible?

    EDIT: I had forgotten to mark my achtion with [ChildActionOnly]. Still does not work but the error message is slightly more descriptive now:

    Type 'Our.Umbraco.NestedContent.Models.DetachedPublishedContent' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 23, 2015 @ 10:23
    Lee Kelleher
    0

    Hi Barry,

    So it's saying that DetachedProductContent objects can be serialized. The original error was with the PublishedItemType enum property - I'm not sure if that's the only problem though.

    I'm curious if regular IPublishedContent (concrete) classes can be serialized? or if they face the same issue?

    I found this on the issue tracker - check out the comments... http://issues.umbraco.org/issue/U4-2522

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft