I have an action in my MVC Controller
public FileStreamResult CustomerOrdersAsExcel(ExcelColumn column)
ExcelColumn model :
public class ExcelColumn
{
public string Header { get; set; }
public List<EnumLocalized> EnumLocalizations { get; set; }
}
then I use ajax to pass my ExcelColumn
let ajaxSettings = {
type: 'GET',
xhrFields: { responseType: 'blob' },
data: column,
contentType: 'application/json; charset=utf-8',
success: (data) => {
... on success
}
}
};
Column is object that has
"{"header":"Order type",
"enumLocalizations":[
{
"key":1,
"value":"Customer order"
},
{
"key":2,
"value":"Webshop"
},
{
"key":4,
"value":"Service order"
}
]}"
Now when I receive data in my controller Header is bound ok, but EnumLocalizations is not. It has 3 elements where each element is filled with default value Key = 0 and Value = null. I have tried to JSON.stringfy this and using traditional: true for jquery settings but neither of that worked. Do you know what may cause that binding fail?
UPDATE: I think the error is in sent format by jquery which is
header:Order type
enumLocalizations[0][key]:1
enumLocalizations[0][value]:Customer order
enumLocalizations[1][key]:2
enumLocalizations[1][value]:Webshop
enumLocalizations[2][key]:4
enumLocalizations[2][value]:Service order
I think it should be something like
header:Order type
enumLocalizations[0].key:1
enumLocalizations[0].value:Customer order
enumLocalizations[1].key:2
enumLocalizations[1].value:Webshop
enumLocalizations[2].key:4
enumLocalizations[2].value:Service order
Do you know how can I change that?