Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asp.net mvc 3 model binder not binding
- @using (Html.BeginForm("LogOn", "Account"))
- {
- <div>
- <fieldset>
- <legend>Account Information</legend>
- <div class="editor-label">
- @Html.LabelFor(m => m.UserName)
- </div>
- <div class="editor-field">
- @Html.TextBoxFor(m => m.UserName, new { style = " width:200px" })
- @Html.ValidationMessageFor(m => m.UserName)
- </div>
- <div class="editor-label">
- @Html.LabelFor(m => m.Password)
- </div>
- <div class="editor-field">
- @Html.PasswordFor(m => m.Password, new { style = " width:200px" })
- @Html.ValidationMessageFor(m => m.Password)
- </div>
- <div class="editor-label">
- @Html.CheckBoxFor(m => m.RememberMe)
- @Html.LabelFor(m => m.RememberMe)
- </div>
- <p>
- <input type="submit" value="Log On" />
- </p>
- </fieldset>
- </div>
- }
- ...
- [HttpPost]
- public ActionResult LogOn(LogOnModel model, string returnUrl)
- {
- Log(new Exception(string.Format("model username : {0}, password : {1}, request[username] {2} , request[password] : {3}", model.UserName, model.Password, Request["UserName"], Request["Password"])));
- try
- {...
- <input type='text' name='your_prefix[RememberMe]' id="your_prefix_RememberMe" />
- ...
- [HttpPost]
- public ActionResult LogOn([Bind(Prefix = "your_prefix")] LogOnModel model, string returnUrl){
- ...
- }
Add Comment
Please, Sign In to add comment