The error occurs when 2 ResourceKey attributes added to the same property of any EPiServer content.
How to reproduce:
Upgrade EPiServer.CMS version to 12.15.0 (AlloySampleSite)
In the file $\samples\AlloySampleSite\Models\Pages\StartPage.cs set KeyPrefix value for LocalizedResource attribute to /ContentTypes/StartPage/ so it matches the current content type
[LocalizedResource(KeyPrefix = "/ContentTypes/StartPage/")]
public class StartPage : SitePageData
Run the site
Open StartPage content in edit mode in CMS
Expected result:
Edit mode works correctly
Actual result:
Request fails /EPiServer/shell/Stores/metadata/EPiServer.Core.ContentData?modelAccessor=%7B%22contentLink%22%3A%2232_88%22%7D with 500 Server Error:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Reflection.AmbiguousMatchException: Multiple custom attributes of the same type found.
at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
at DbLocalizationProvider.ResourceKeyBuilder.BuildResourceKey(Type containerType, String memberName, String separator) in C:\projects\3rdparty\localization-provider-epi\lib\netcore\lib\localization-provider\src\DbLocalizationProvider\ResourceKeyBuilder.cs:line 150
at DbLocalizationProvider.AspNetCore.DataAnnotations.ModelMetadataLocalizationHelper.GetTranslation(Type containerType, String propertyName) in /_/src/DbLocalizationProvider.AspNetCore/DataAnnotations/ModelMetadataLocalizationHelper.cs:line 55
at DbLocalizationProvider.AspNetCore.DataAnnotations.LocalizedDisplayMetadataProvider.<>c__DisplayClass3_0.<CreateDisplayMetadata>b__1() in /_/src/DbLocalizationProvider.AspNetCore/DataAnnotations/LocalizedDisplayMetadataProvider.cs:line 56
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_DisplayName()
at EPiServer.Shell.ObjectEditing.ExtendedMetadata.ReadSettingsFromDisplayAttributes(IEnumerable`1 attributes)
at EPiServer.Shell.ObjectEditing.ExtendedMetadata.InitializeFromAttributes(IEnumerable`1 attributes)
at EPiServer.Cms.Shell.UI.Internal.ContentDataMetadataProvider.ExtractSettingsFromAttributes(ContentDataMetadata metadata, IEnumerable`1 attributes)
at EPiServer.Cms.Shell.UI.Internal.ContentDataMetadataProvider.CreateMetadata(IEnumerable`1 attributes, Type containerType, Func`1 modelAccessor, Type modelType, String propertyName)
at EPiServer.Cms.Shell.UI.Internal.ContentDataMetadataProvider.GetContentDataMetaData(Type propertyDataType, IContentData content, HashSet`1 groups)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.GetExtendedMetadataForProperties(ExtendedMetadata parent, Object container, Type containerType, IMetadataProvider customProvider)
at EPiServer.Shell.ObjectEditing.ExtendedMetadata.get_Properties()
at EPiServer.Cms.Shell.UI.ObjectEditing.InternalMetadata.ReloadOnChangeMetadataExtender.ModifyMetadata(ExtendedMetadata metadata, IEnumerable`1 attributes)
at EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.ApplyExtendersToMetadata(ExtendedMetadata metadata, IEnumerable`1 attributes, IEnumerable`1 metadataHandlers)
at EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.GetExtendedMetadata(IEnumerable`1 attributes, Type containerType, Func`1 modelAccessor, Type modelType, String propertyName)
at EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.GetExtendedMetadataForType(Type modelType, Func`1 modelAccessor)
at EPiServer.Shell.UI.Rest.MetadataStore.Get(String id, String modelAccessor)
at lambda_method289(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at AlloySampleSite.Infrastructure.AdministratorRegistrationPageMiddleware.InvokeAsync(HttpContext context) in C:\projects\3rdparty\localization-provider-epi\samples\AlloySampleSite\Infrastructure\AdministratorRegistrationPageMiddleware.cs:line 31
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Hello,
The error occurs when 2
ResourceKey
attributes added to the same property of any EPiServer content.How to reproduce:
EPiServer.CMS
version to12.15.0
(AlloySampleSite)$\samples\AlloySampleSite\Models\Pages\StartPage.cs
setKeyPrefix
value forLocalizedResource
attribute to/ContentTypes/StartPage/
so it matches the current content typeStartPage
content in edit mode in CMSExpected result: Edit mode works correctly
Actual result: Request fails
/EPiServer/shell/Stores/metadata/EPiServer.Core.ContentData?modelAccessor=%7B%22contentLink%22%3A%2232_88%22%7D
with 500 Server Error: