我有一个简单的登录表单,我通过这样的Razor渲染 -
<div class="row">
@Html.TextBoxFor(m => m.EMail, htmlAttributes: new { @class = "form-control", placeholder = "E-Mail" })
@Html.PasswordFor(m => m.Password, htmlAttributes: new { @class = "form-control", placeholder = "Password" })
@Html.CheckBoxFor(m => m.RememberMe, htmlAttributes: new {@class = "form-control", value="1", @checked = "1"})
<input type="button" class="btn btn-sm btn-primary" id="signinbutton" value="Sign In" />
</div>
它在页面上正确呈现,但是当我尝试序列化时,这是输出 -
EMail=Sam&Password=sam&RememberMe=1&RememberMe=false
RememberMe
已连续两次序列化。
当我深入研究生成的html时,输入字段会生成两次 -
<input checked="1" data-val="true" data-val-required="The RememberMe field is required." id="RememberMe" name="RememberMe" type="checkbox" value="1">
<input name="RememberMe" type="hidden" value="false">
它看起来很奇怪。我不确定为什么会这样。有任何想法吗?