EditorFor/CheckBoxFor boolean adds data-val-required attribute to HTML without required attribute being added to model
问题 My model class has a bool property without a Required attribute: public class Test { public bool TestBool1 { get; set; } } Then in my razor view I am using EditorFor (Same thing happens with CheckBoxFor as well): <div> @Html.LabelFor(m => m.TestBool1) @Html.EditorFor(m => m.TestBool1) </div> This results in the following HTML: <div> <label for="TestBool1">TestBool1</label> <input class="check-box" data-val="true" data-val-required="The TestBool1 field is required." id="TestBool1" name=