Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is definitely a bug. I just spent hours debugging the MVC 4 source code for the same problem. The primary root cause it that you have a collection whose name is the beginning of another property name. In your example: pl and pl-odd-value. </p> <p>If you play around some more, you may find that sometimes it works properly. The reason for it seeming to be random is that the model binder performs a binary search to locate the value to bind. The binary search uses a "divide and conquer" approach to finding the property in a sorted list of the properties that were posted. If the search tests the p1-odd-value in its divide and conquer, the problem occurs. If the search skips this value, no problem.</p> <p>This problem is most repeatable when you simply have the pl collection with 1 element and the pl-odd-value property in the object. </p> <p>Here is a bit more info related to this. There is a sortedList of all of the values posted back. In the case of your failed test, the sorted list looks like this:</p> <pre><code>alc, "false", al[0], "386" al[1], "710" pl-odd-value, "false" pl[0], "9530" pl[1], "211" pl[2], "783" </code></pre> <p>Notice that the sort order uses StringComparer.OrdinalIgnoreCase, which places the square bracket items AFTER the text-only item. When MVC is performing its binary search for the al or pl collection, it is searching for al or pl, NOT al[ or pl[. By searching for the collection name without a square bracket, al &lt; alc, not greater than alc. Problem is that we want to look after alc or pl-odd-value to get to the collection. </p> <p>The workaround is to make sure that none of your property names start with the name of any of your collection property names. Rename your al collection to maybe al_collection and your pl collection to maybe pl_collection.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload