This project is read-only.

DisplayNameAttribute not used for Validation

Topics: ASP.NET Web API
Dec 12, 2013 at 1:25 AM
Property Names are used instead. This is different from MVC and makes localization difficult. Is this going to change or is there an easy way to work around it? Thanks.
Dec 12, 2013 at 5:40 AM

Can you use “System.ComponentModel.DataAnnotations.DisplayAttribute” attribute instead? This attribute allows you to provide ResourceType for localization purposes whereas DisplayName does not.

Which version of Web API are you using? In Web API 2 a bug was fixed to make it correctly work for DisplayAttribute.



Dec 13, 2013 at 4:44 AM
Edited Dec 13, 2013 at 5:02 AM
The problem is it just completely ignores the DisplayNameAttribute even if I just hard code a string. I can't use DisplayAttribute because it's a sealed class and we have custom localization so I have to be able to inherit. Thanks.
        public string TerriblePropertyName { get; set; }
Dec 13, 2013 at 4:47 AM
Ok...just want to confirm, did this work before and isn't now?

Sent from my Windows Phone

Dec 13, 2013 at 5:02 AM
I don't know I've only tried it in Web API 2.