I think ApplicationPage is missing inherited Episerver type, tyically ContentData
I've used ContentReferences on PropertyLists and I've been able to import and export successfully between environments. I have noted that where Url properties are used, these have needed decorating with the [JsonConverter(typeof(UrlConverter))] attribute if you want to use them in a property list or if you want to use it on a content type that will be imported and exported between systems. I believe this is because the import / export mechanism uses json files.
This may actually be failing because there is a missing json convertor for PageReference, you could try writing your own simple convertor for this?
Absolutely Stotty. We can add a PageReference converter like the one for UrlConverter.
[ServiceConfiguration(typeof(JsonConverter))]
public class PageReferenceConverter : JsonConverter
{
public override bool CanConvert(Type objectType) => typeof(PageReference).IsAssignableFrom(objectType);
public override object ReadJson(
JsonReader reader,
Type objectType,
object existingValue,
JsonSerializer serializer)
{
return reader.Value != null ? (object)new PageReference(reader.Value.ToString()) : (object)null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is PageReference pageReference) || PageReference.IsNullOrEmpty(pageReference))
writer.WriteValue(string.Empty);
else
writer.WriteValue(value.ToString());
}
}
~ Sujit
When PropertyList is saved/loaded from db it does not use the converters registered in IOC container since those are used when sending/getting data from the client and that format is not nessecarily the same format as we want to persist in database. So to get you converter to be used when loading/persisting data from database you need to decorate your PageReference property on your model, like:
[JsonConverter(typeof(PageReferenceConverter))]
public PageReference Page { get; set; }
Hi guys,
We have a PropertyListBase
and Application page as
This property works fine and we get a nice interface in edit mode, where we can enter multiple items and each item has a page reference and a string.
We have exported this page and trying to import in a new env, but getting the following error Unable to cast object of type 'EPiServer.Core.UnresolvedContentReference' to type 'EPiServer.Core.PageReference'.] & the import fails.
All the pages that are selected within this property are part of the export package.
Anyone know how can I make this work?
Thanks