1

Option 1: If I deserialize my JSON request manually, I get a correct result:

[Route("search")]
[HttpPost]
public IEnumerable<ErrorLogDto> Search(HttpRequestMessage request)
{
    string res = request.Content.ReadAsStringAsync().Result;
    LogSearchDto dto = JsonConvert.DeserializeObject(res, typeof(LogSearchDto)) as LogSearchDto;
    //dto = not null

Option 2: If I use this, I always get NULL value for dto:

[Route("search")]
[HttpPost]
public IEnumerable<ErrorLogDto> Search([FromBody]LogSearchDto dto)
{
// dto = null!

I am out of ideas how to debug this..

1 Answer 1

1

After a long search, I solved the problem by removing following lines from Global.asax.cs:

var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.UseDataContractJsonSerializer = true;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.