0

I have written a custom attribute. In the error message I have special characters. due to these special characters, ValidationAttribute.FormatErrorMessage(GetDisplayName()) throwing Input string was not in a correct format error.

My error message is @"Your characters should be in: ^_{}~".

How can I fix this issue?

Ashok Yaganti
  • 173
  • 5
  • 14

1 Answers1

0

The error is because of {}. It has special meaning in c#. So you have to use escape character for that. ex: (ErrorMessage = "Your characters should be in: !#$%&()*+,-./:;<=>?@[]^_{{|}}~"

So for escaping {, you have to use double {.