I don't understand why only the string property Search.Value is not being deserialized in my ASP.NET MVC5 Controller. Please see this:
The Json-structure sent from the Client:
{
"draw":1,
// ...
"start":0,
"length":50,
"search":{
"value":"This is always null in my controller",
"regex":false
}
}
The model I have server-side:
public class AsyncDataTableRequest
{
public int Draw { get; set; }
public int Start { get; set; }
public int Length { get; set; }
public Search Search { get; set; }
public string Value { get; set; }
}
public class Search
{
public string Value { get; set; }
public bool Regex { get; set; }
}
The controller where I would like to do something with Search.Value:
public JToken AsyncLogFetching(AsyncDataTableRequest req)
{
// req.Search.Value is null here, all other properties seem correct
...
}
Thank you for any help!
Edit: For a sample search with "NewYork", this the request from the tab "request header" in IE Developer tools:
GET /Log/AsyncLogFetching?draw=3&start=0&length=50&search%5Bvalue%5D=NewYork&search%5Bregex%5D=false&_=1438350434912 HTTP/1.1
The tab "request text" in IE Developer tools says "No data to display".
This is the snippet that does the GET-Request, it's copy & pasted from the jQuery DataTables Pipelining example:
settings.jqXHR = $.ajax({
"type": conf.method, // GET
"url": conf.url,
"data": request,
"dataType": "json",
"contentType": "application/json",
"cache": false,
"success": function (json) {
// ...
}
});