简体   繁体   中英

How to add items to the additional-values collection ModelMetadata with ASP.NET Core using attributes?

I have an application written using C# on the top of ASP.NET Core 5.0 framework. I am looking for the right way to add items to the ModelMetadata.AdditionalValues collection.

In ASP.NET MVC 5, we had IMetadataAware in which we used in addition to Attribute tag to add items to the ModelMetadata.AdditionalValues collection. With ASP.NET Core however, the IMetadataAware no longer exists.

你可以尝试使用自定义模型元数据接口。 在AddMvcOptions 添加options.ModelMetadataDetailsProviders.Add(new CustomDisplayMetadataProvider()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM