Skip to content

Commit 86df335

Browse files
author
Ron Petrusha
authored
Revised ValidationContext.MemberName (#2366)
* Revised ValidationContext.MemberName * Update xml/System.ComponentModel.DataAnnotations/ValidationContext.xml Corrected typo. Co-Authored-By: rpetrusha <[email protected]>
1 parent 65c1e13 commit 86df335

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

xml/System.ComponentModel.DataAnnotations/ValidationContext.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,20 @@
339339
<remarks>
340340
<format type="text/markdown"><![CDATA[
341341
342-
## Remarks
343-
This property represents an entity member name, not the name of a corresponding data field. Therefore, this name is not a localized name. It should be set only for property or parameter contexts.
344-
342+
## Remarks
343+
344+
This property represents an entity member name, not the name of a corresponding data field. Therefore, this name is not a localized name. It should be set only for property or parameter contexts.
345+
346+
In .NET Framework 4.7.2 and earlier versions, when using a custom <xref:System.ComponentModel.DataAnnotations.ValidationAttribute?displayProperty=nameWithType>, the `MemberName` property returns `null`. Starting with .NET Framework 4.8, you can change the default behavior so that the property returns the member name by adding the following setting to your app config file:
347+
348+
```xml
349+
<configuration>
350+
<appSettings>
351+
<add key="aspnet:GetValidationMemberName" value="true" />
352+
</appSettings>
353+
</configuration>
354+
```
355+
345356
]]></format>
346357
</remarks>
347358
</Docs>
@@ -450,4 +461,4 @@
450461
</Docs>
451462
</Member>
452463
</Members>
453-
</Type>
464+
</Type>

0 commit comments

Comments
 (0)