ASP.NET Core: Blank Json Return After Upgrading to 3.0

After upgrading an application from ASP.NET Core 2.2 to ASP.NET Core 3.0, I had some issues where controller methods in an application were returning populated objects, but the HTTP responses were blank Json documents: {}. To make matters worse, there were no exceptions thrown — the application was just silently sending blank documents to the browser.

When I changed the return to a simple class, it worked correctly and returned a valid Json document. The problem is that .NET Core 3.0 now defaults to System.Text.Json rather than NewtonSoft Json.NET. Microsoft cautions that the new System.Text.Json has some limitations, but it’s quite confusing that when the new library has issues serializing objects, controller methods output blank documents without exceptions or easily apparent errors. In my case, my objects weren’t what I’d consider complicated — just several layers of inheritance and a few attributes.

What fixed it for me was simply switching back to NewtonSoft Json.NET. Microsoft explains the process here: