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.
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?
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.
Hi Barry,
So it's saying that
DetachedProductContent
objects can be serialized. The original error was with thePublishedItemType
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
is working on a reply...