Shot in the dark here, try removing the interface and include the following using
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
After some reading
"One thing that has been removed in MVC6 is the IMetadataAware
interface. This allowed you to create your own subclasses of Attribute that could add data to the ModelMetadata
structure to be used in an EditorTemplate or DisplayTemplate view."
See more info here : Reinstating IMetadataAware in ASP.NET 5 vNext MVC 6 (emikek.com)
Hello,
After upgrading to all Episerver nuget packages to latest stable versions of CMS12, we are seeing a casting issue:
Message=Unable to cast object of type 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DisplayMetadata' to type 'EPiServer.Shell.ObjectEditing.ExtendedMetadata'.
Sample Code:
namespace KK.Opti.Common.Menu.Infrastructure.Attributes
{
public class PropertyListLinkAttribute : Attribute, IMenuModelMetadataAware
{
public Injected<IUrlResolver> UrlResolver { get; set; }
public Dictionary<string, string> LinkMappings { get; set; }
public virtual void OnMetadataCreated(DisplayMetadata metadata)
{
var extendedMetadata = (ExtendedMetadata)metadata;
var list = ((MenuItemProperty)extendedMetadata.Model).List;
}
Any help is appreciated.