DisplayFor ignores metadata
- by Juvaly
For my Contact class, the property EmailAddress is marked with the [DataType(DataType.EmailAddress)] attribute.
In my view, using Html.Display("EmailAddress") and Html.DisplayFor(c => c.EmailAddress) yields different results. The former outputs a mailto: link, which is the expected behavior, while the latter simply outputs the email address as plain text.
My question is why the different behavior, I expected these two methods to have the same output.