I'm using C# and MVC 5, but for some reason my view is passing an anonymous type back to the controller, and it's not happy about that. The specific error is:
An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Core.dll but was not handled in user code
Additional information: 'object' does not contain a definition for 'Id'
This is the specific controller function signature:
[HttpPost, ParameterBasedOnFormName("save-continue", "continueEditing")]
public ActionResult TaskEdit(dynamic model, bool continueEditing)
The error occurs when I try to reference model.Id
in that function. The beginning of the view is this:
@model ProjectModelShopModel
// ...
@using (Html.BeginForm(null, null, FormMethod.Post, Model))
{
// code
}
How do I solve this error? I can provide more code if necessary.
EDIT: I use a dynamic type in TaskEdit
because three views call that function, each with a different model. The function is nearly identical in each. I don't use inheritance because I screwed up too much early on and it would take way too much work to fix now.