When creating a new class model, if you apply the Data Annotation type "[DataType(DataType.EmailAddress)]", or "[EmailAddress]", I get the raw output being displayed in my HTML.
// In ~/Models/Product.cs
// using System.ComponentModel.DataAnnotations;
public class Product
{
[DataType(DataType.EmailAddres)]
public string Publisher { get; set; }
}
And in my Razor HTML, I have:
// In ~/Views/Products/Index.cshtml
<table class="table">
<tbody>
@foreach (var item in Model)
{
// gets displayed as a literal string format instead of data from database
<tr title="Published by: @Html.DisplayFor(modelItem => item.Publisher)"></tr>
}
</tbody>
</table>
For instance, say I have 3 records in my database "Product". The Razor HTML code loops through the database to display each record.
By applying the Data Annotation "[DataType(DataType.EmailAddres)]" or "[EmailAddress]", it seems to cause some weird effect of converting it into a literal string, meaning that instead of displaying the data from the database in the correct way, which is 'Published by: [email protected]', it instead outputs it as a single liner string '[email protected] > [email protected] > [email protected] >' in the View.
Does anyone have any idea as to why this is the case?
For additional information, I'm using ASP.NET Core version 3.0 MVC, though if I recall, this was also present in version 2.1.

DisplayForreturns an actual HTML anchor tag (i.e. link) with the email for an email type. That's invalid inside of an HTML attribute, causing the HTML to break. If all you want is the email address string itself, just print it directly (i.e.@item.Publisher), rather than usingHtml.DisplayFor. - Chris Pratt