Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: FormValueProvider does not recognize array item members from jQuery posts [1564]

$
0
0
This bug occurs when using jQuery POST to send complex JavaScript objects to the server as encoded HTTP form data.

For example, if I need to post the following object:
```
{
singleProperty: 'hello',
arrayProperty: [
{
propertyOne: 1,
propertyTwo: 'Two',
},
{
propertyOne: 2,
propertyTwo: 'Four',
},
{
propertyOne: 3,
propertyTwo: 'Six',
}
]
}
```

Then when jQuery posts that object as form data, it posts the following (line breaks added for readability):

"singleProperty=hello&
arrayProperty[0][propertyOne]=1&
arrayProperty[0][propertyTwo]=Two&
arrayProperty[1][propertyOne]=2&
arrayProperty[1][propertyTwo]=Four&
arrayProperty[2][propertyOne]=3&
arrayProperty[2][propertyTwo]=Six"

But ASP.NET MVC is expecting this (line breaks added for readability):

"singleProperty=hello&
arrayProperty[0].propertyOne=1&
arrayProperty[0].propertyTwo=Two&
arrayProperty[1].propertyOne=2&
arrayProperty[1].propertyTwo=Four&
arrayProperty[2].propertyOne=3&
arrayProperty[2].propertyTwo=Six"

The result of this discrepancy is that the properties inside of each of the collection elements of the action parameter object are all defaulted.

I have attached a small project that exemplifies this behavior.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>