Question

I started getting this error when posting the form back with Model Binder. To test the problem I reduced the postback to one string property of the model but i still get the overflow error. Can anyone suggest what would cause this?

UPDATE The problem appears to be related to the property in the model that is a foreign key. If this key is removed, the binding works. How can I do the binding and include the foreign key relationship?

Was it helpful?

Solution

You can fix this a few ways. One way is to try something like this.

public ActionResult AddProduct([Bind(Exclude = "Category")]Product product) { }

This tells the model binder to not try to bind the Category (FK property). This is a known issue and the MVC team has already fixed it for RC.

You can also pass in an exclusion list into UpdateModel/TryUpdateModel and any place you add a Bind attribute.

OTHER TIPS

A stack overflow is usually due to infinite recursion. Look through the stack trace and see if you see the same function (or group of functions) over and over again. That would indicate that a recursive function is never reaching its base case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top