Guest User

Untitled

a guest
Aug 11th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. asp.net mvc 3 model binder not binding
  2. @using (Html.BeginForm("LogOn", "Account"))
  3. {
  4. <div>
  5. <fieldset>
  6. <legend>Account Information</legend>
  7. <div class="editor-label">
  8. @Html.LabelFor(m => m.UserName)
  9. </div>
  10. <div class="editor-field">
  11. @Html.TextBoxFor(m => m.UserName, new { style = " width:200px" })
  12. @Html.ValidationMessageFor(m => m.UserName)
  13. </div>
  14. <div class="editor-label">
  15. @Html.LabelFor(m => m.Password)
  16. </div>
  17. <div class="editor-field">
  18. @Html.PasswordFor(m => m.Password, new { style = " width:200px" })
  19. @Html.ValidationMessageFor(m => m.Password)
  20. </div>
  21. <div class="editor-label">
  22. @Html.CheckBoxFor(m => m.RememberMe)
  23. @Html.LabelFor(m => m.RememberMe)
  24. </div>
  25. <p>
  26. <input type="submit" value="Log On" />
  27. </p>
  28. </fieldset>
  29. </div>
  30. }
  31. ...
  32. [HttpPost]
  33. public ActionResult LogOn(LogOnModel model, string returnUrl)
  34. {
  35. Log(new Exception(string.Format("model username : {0}, password : {1}, request[username] {2} , request[password] : {3}", model.UserName, model.Password, Request["UserName"], Request["Password"])));
  36. try
  37. {...
  38.  
  39. <input type='text' name='your_prefix[RememberMe]' id="your_prefix_RememberMe" />
  40. ...
  41.  
  42. [HttpPost]
  43. public ActionResult LogOn([Bind(Prefix = "your_prefix")] LogOnModel model, string returnUrl){
  44. ...
  45. }
Add Comment
Please, Sign In to add comment