There is another way to do it, too, without having to create your own extension.
Say for instance we have the following in one of our controllers:
ModelState.AddModelError("Name", "<b>Please Use a Valid Person Name</b>");
We can then do the following in our view:
@if(Html.ValidationMessageFor(x => x.Name) != null){
@Html.Raw(Html.ValidationMessageFor(x => x.Name).ToString())
}
The will prevent the error message of '<b>Please Use a Valid Person Name</b>'
from being encoded.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…