Skip to content

Remarks on ValidationContext.MemberName don't appear to reflect reality #5002

Open
@IanKemp

Description

@IanKemp

https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.validationcontext.membername?view=netframework-4.6.1 states:

In .NET Framework 4.7.2 and earlier versions, when using a custom System.ComponentModel.DataAnnotations.ValidationAttribute, the MemberName property returns null.

My .NET Framework web app has numerous custom ValidationAttributes (I assume "custom" = "derived from") and the MemberName property is very much non-null on the ValidationContexts passed into those attributes' overridden IsValid(object, ValidationContext) method. The catch is that (a) the app targets Framework 4.6.1 (b) there is no aspnet:GetValidationMemberName setting defined in its web.config file. In other words, what I'm seeing directly contradicts what the documentation claims.

I have the following Framework versions installed:

.NET FW 3.5 SP 1 (CLR 2.0)
.NET FW 4.6.2 Windows 10 May 2020 Update(CLR 4.0)
.NET FW 4.7 Windows 10 May 2020 Update(CLR 4.0)
.NET FW 4.7.1 Windows 10 May 2020 Update(CLR 4.0)
.NET FW 4.7.2 Windows 10 May 2020 Update(CLR 4.0)
.NET FW 4.8 Windows 10 May 2020 Update(CLR 4.0)

so my assumption is that my app is actually being run by 4.8, but even so that does not explain the missing web.config setting.

Please can you advise why this is working for me, and/or update the documentation to clarify.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions