Asp – bug in ASP.Net MVC 2 RC version for UpdateModel()

asp.net-mvc-2

I'm trying to implement MVC 2 RC version, the latest release of ASP.Net MVC and it can't do a simple Controller.UpdateModel(object) without throwing this exception:

The model of type '[Insert namespace of object being updated here]' could not be updated.

InvalidOperationException

Here's the stack trace:

at System.Web.Mvc.Controller.UpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)
at System.Web.Mvc.Controller.UpdateModel[TModel](TModel model)
at Ccis.Cgov360.Web.InternalApp.Controllers.AdminController.MailingLabelTypeSelected() in C:\Projects\Meadowlark\Development\Meadowlark\Applications\InternalApp\Controllers\AdminController.cs:line 1528
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

When I use MVC Preview 2 it functions and updates the model just fine with no exceptions thrown. I saw elsewhere that there is a bug in RC version, is this the same thing?

I've spent way too much time trying to fix this issue. I was hoping to get the RC release so that we can start using the Html helpers such as TextBoxFor<>, CheckBoxFor<>, etc. and the client-side validation.

Best Answer

I also ran into this issue.

As a work-around, I am just calling TryUpdateModel() instead of UpdateModel().

Related Topic