This article is a mirror article of machine translation, please click here to jump to the original article.

View: 38237|Reply: 1

[.NET Core] ASP.NET Core receives POST JSON parameters that cannot be serialized into objects

[Copy link]
Posted on 2021-1-21 18:24:30 | | | |
When trying to post json content to the asp.net core backend, the backend object is always null, and the network request is as follows:



{"draw":1,"columns":[{"data":"userName","name":"","searchable":true,"orderable":false,"search":{"value":"","regex":false}},{"data":"nickName","name":"","searchable": true,"orderable":false,"search":{"value":"","regex":false}},{"data":"deptCode","name":"","searchable":true,"orderable":false,"search":{"value":"","regex":false}},{" data":"_CreateTime","name":"","searchable":true,"orderable":false,"search":{"value":"","regex":false}},{"data":"disabled","name":"","searchable":true,"orderable": false,"search":{"value":"","regex":false}}],"order":[{"column":0,"dir":"asc"}],"start":0,"length":20,"search":{"value":"","regex":false},"SearchPar":{"userName":""}}


content-type: application/json; charset=UTF-8

The background code is as follows:



Changing the object to a simple type is acceptable normally, is it a generic problem? Finally, it was discovered that it seemed that the enum type was not receiving properly, causing the entire object to be null.

Solution:

Deserialize objects using NewtonsoftJson, defaultProbably soSystem.Text.Json

The nuget command is as follows:

Startup modifications are as follows:
(End)




Previous:Deploy Jaeger distributed link tracing tutorial with Docker
Next:.NET/C# is based on the BlockingCollection background task queue
Posted on 2021-10-5 17:57:07 |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com