yash patel

yash patel

  • 1.4k
  • 286
  • 21.4k

System.InvalidOperationException

Oct 1 2020 6:17 AM
This is my action method for new user registration and update user
  1. public ActionResult SignUp(User obj)  
  2. {  
  3. if(obj != null)  
  4. {  
  5. return View(obj);  
  6. }  
  7. else  
  8. {  
  9. return View();  
  10. }  
  11. }  
This is view page
  1. @model nsroute.BusinessObject.UserBO  
  2. @{  
  3. ViewBag.Title = "Sign Up";  
  4. }  
  5. <body class="login">  
  6. <div class="wrapper wrapper-login">  
  7. <div class="container container-login animated fadeIn">  
  8. <img class="logo" src="~/Content/assets/img/logo.jpg" />  
  9. @using (Html.BeginForm("SignUp""Account", FormMethod.Post))  
  10. {  
  11. <h3 class="text-center">Register</h3>  
  12. <div class="login-form">  
  13. <div class="form-group">  
  14. @Html.HiddenFor(model=>model.UserId)  
  15. @Html.LabelFor(model => model.FullName, new { @class = "placeholder" })  
  16. @Html.TextBoxFor(model => model.FullName, new { @class = "form-control" })  
  17. </div>  
  18. <div>  
  19. @Html.ValidationMessageFor(model => model.FullName, nullnew { @class = "text text-danger" })  
  20. </div>  
  21. <div class="form-group">  
  22. @Html.LabelFor(model => model.UserEmail, new { @class = "placeholder" })  
  23. @Html.TextBoxFor(model => model.UserEmail, new { @class = "form-control" })  
  24. </div>  
  25. <div>  
  26. @Html.ValidationMessageFor(model => model.UserEmail, nullnew { @class = "text text-danger" })  
  27. </div>  
  28. <div class="form-group">  
  29. @Html.LabelFor(model => model.Password, new { @class = "placeholder" })  
  30. @Html.PasswordFor(model => model.Password, new { @class = "form-control" })  
  31. </div>  
  32. <div>  
  33. @Html.ValidationMessageFor(model => model.Password, nullnew { @class = "text text-danger" })  
  34. </div>  
  35. <div class="form-group">  
  36. @Html.LabelFor(model => model.ConfirmPassword, new { @class = "placeholder" })  
  37. @Html.PasswordFor(model => model.ConfirmPassword, new { @class = "form-control" })  
  38. </div>  
  39. <div>  
  40. @Html.ValidationMessageFor(model => model.ConfirmPassword, nullnew { @class = "text text-danger" })  
  41. </div>  
  42. <div class="form-group">  
  43. @Html.LabelFor(model => model.CompleteAddress, new { @class = "placeholder" })  
  44. @Html.TextBoxFor(model => model.CompleteAddress, new { @class = "form-control" })  
  45. </div>  
  46. <div>  
  47. @Html.ValidationMessageFor(model => model.CompleteAddress, nullnew { @class = "text text-danger" })  
  48. </div>  
  49. <div class="form-group">  
  50. @Html.LabelFor(model => model.City, new { @class = "placeholder" })  
  51. @Html.TextBoxFor(model => model.City, new { @class = "form-control" })  
  52. </div>  
  53. <div>  
  54. @Html.ValidationMessageFor(model => model.City, nullnew { @class = "text text-danger" })  
  55. </div>  
  56. <div class="form-group">  
  57. @Html.LabelFor(model => model.State, new { @class = "placeholder" })  
  58. @Html.TextBoxFor(model => model.State, new { @class = "form-control" })  
  59. </div>  
  60. <div>  
  61. @Html.ValidationMessageFor(model => model.State, nullnew { @class = "text text-danger" })  
  62. </div>  
  63. <div class="form-group form-action-d-flex mb-3">  
  64. <input type="submit" value="Submit" class="btn btn-primary w-100 fw-bold" />  
  65. </div>  
  66. <div class="login-account">  
  67. <span class="msg">Already a Member , </span>  
  68. <a href="@Url.Action("Login", "Account")" id="show-signup" class="link">Login Here</a> !  
  69. </div>  
  70. </div>  
  71. }  
  72. </div>  
  73. </div>  
  74. </body>  
when clicking on update button the id including all other values is passed it is showing in the url also
 
but getting this error
 
The model item passed into the dictionary is of type 'nsroute.DataAccess.User', but this dictionary requires a model item of type 'nsroute.BusinessObject.UserBO'.

Answers (3)