'Why it occurs this error [The JSON value could not be converted to System.Nullable] when ASP.NET Core is upgraded from 2.1 to 3.1?

When upgrading an ASP.NET Core 2.1 application to 3.1, I encountered an error : The JSON value could not be converted to System.Nullable. What is going on and how should this problem be solved?



Solution 1:[1]

I think you use the old jsonoption in ConfigureService. Since starting from ASP.NET Core 3.0, its default built-in JSON serialization and deserialization library is System.Text.Json. This library does not implement JSON conversion of these special data types like Json.NET. , so you can add nuget package newtonsoft to replace the built-in JSON serialization library System.Text.Json. And configure it in startup.

services.AddControllers().AddNewtonsoftJson();

Solution 2:[2]

I got this error too. The problem is that the information from the front is not in the correct format and if you are using frombody .net throws this error when it cannot convert it. I had this mistake in the byte array.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Karney.
Solution 2 Samur Aganiyev