Fixing System.StackOverflowException was unhandled (MVC Model BINDING)

I started getting this error when submitting the form back using Binding. To test the problem, I minified the backreference to one property of the model string, but I still get an overflow error. Can anyone suggest what might be causing this?

UPDATE The problem seems to be with a property in a model that is a foreign key. If this key is removed, the binding works. How can I bind and enable foreign key relationships?

+1


source to share


2 answers


There are several ways you can fix this. One way is to try something like this.

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

      



This says the linker is not trying to bind a category (FK property). This is a known issue and the MVC team has already installed it for RC.

You can also pass the list of exceptions to UpdateModel / TryUpdateModel and wherever you add the Bind attribute.

+1


source


Stack overflow usually occurs due to infinite recursion. Look at the stack trace and see if you see the same function (or group of functions) over and over. This would mean that the recursive function never reaches its base case.



0


source







All Articles