I have a variable which has values and I am trying to add to DB using TryUpdateModel and eventually it doesn't happen.
Getting below error message.
- [HttpPost]
- public ActionResult CreateAccount(FormCollection collection)
- {
- string msg = string.Empty;
- try
- {
- var accountdetail = new AccountDetail();
- TryUpdateModel(accountdetail);
- AccountRepository userRepo = new AccountRepository();
- if (userRepo.CreateUser(EntityHelper.InitializeUser(accountdetail, 0)))
- return Json(new { Result = "Success", InfoMsg = msg });
- else
- msg = "Error returned";
- }
- catch (Exception ex)
- {
- msg = ex.Message;
- }
- return Json(new { Result = "Failed", InfoMsg = msg });
- }
Error Message:
Property set method not found.
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at PerpetuumSoft.Knockout.KnockoutUtilities.ConvertData(Object data)
at PerpetuumSoft.Knockout.KnockoutUtilities.ConvertData(Object data)
at PerpetuumSoft.Knockout.KnockoutModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model)
at WebApp.Controllers.AccountController.CreateAccount(FormCollection collection) in C:\Code\AccountController.cs:line 166
Exception is thrown at this line
TryUpdateModel(accountdetail);
Really appreciate any inputs.