Where did IMvcBuilder AddJsonOptions go in .Net Core 3.0?

I’ve just upgraded my ASP web API project from .Net core 2.0 to 3.0. I was using

             .AddJsonOptions(options =>options.SerializerSettings.ContractResolver 
                                       = new DefaultContractResolver());

previously to ensure lower-casing of the serialized JSON.

After the upgrade to 3.0 I get this error:

Error CS1061 ‘IMvcBuilder’ does not contain a definition for
‘AddJsonOptions’ and no accessible extension method ‘AddJsonOptions’
accepting a first argument of type ‘IMvcBuilder’ could be found (are
you missing a using directive or an assembly reference?)

According to AddJsonOptions for MvcJsonOptions in Asp.Net Core 2.2 the AddJsonOptions extension method is/was provided by the Microsoft.AspNetCore.Mvc.Formatters.Json nuget package. I have tried installing/reinstalling this but still can’t resolve the method. Interestingly, intellisense only shows Microsoft.AspNetCore.Mvc.Formatters.Xml when I try to add the using statement even though I added the Json nuget package.

Any ideas what is going on? The documentation for AddJsonOptions only goes up to .Net 2.2 so perhaps the method has been deprecated in 3.0 in favor of some other configuration mechanism?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

As part of ASP.NET Core 3.0, the team moved away from including Json.NET by default. You can read more about that in general in the announcement on breaking changes to Microsoft.AspNetCore.App.

Instead of Json.NET, ASP.NET Core 3.0 and .NET Core 3.0 include a different JSON API that focuses a bit more on performance. You can learn about that more in the announcement about “The future of JSON in .NET Core 3.0”.

The new templates for ASP.NET Core will no longer bundle with Json.NET but you can easily reconfigure the project to use it instead of the new JSON library. This is important for both compatibility with older projects and also because the new library is not supposed to be a full replacement, so you won’t see the full feature set there.

In order to reconfigure your ASP.NET Core 3.0 project with Json.NET, you will need to add a NuGet reference to Microsoft.AspNetCore.Mvc.NewtonsoftJson, which is the package that includes all the necessary bits. Then, in the Startup’s ConfigureServices, you will need to configure MVC like this:


This sets up MVC controllers and configures it to use Json.NET instead of that new API. Instead of controllers, you can also use a different MVC overload (e.g. for controllers with views, or Razor pages). That AddNewtonsoftJson method has an overload that allows you to configure the Json.NET options like you were used to with AddJsonOptions in ASP.NET Core 2.x.

    .AddNewtonsoftJson(options =>
        options.SerializerSettings.ContractResolver = new DefaultContractResolver();

Method 2

This worked for me, while using .Net Core 3:

services.AddMvc().AddJsonOptions(o =>
    o.JsonSerializerOptions.PropertyNamingPolicy = null;
    o.JsonSerializerOptions.DictionaryKeyPolicy = null;

Method 3

Make sure that you installed the Microsoft.AspNetCore.Mvc.NewtonsoftJson package.

Where did IMvcBuilder AddJsonOptions go in .Net Core 3.0?

Method 4

This would help

public void ConfigureServices(IServiceCollection services)
            services.AddControllers().AddJsonOptions(options=> {  options.JsonSerializerOptions.PropertyNamingPolicy = null;
                 options.JsonSerializerOptions.DictionaryKeyPolicy = null;


            services.AddDbContext<PaymentDetailContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DevConnection")));

Method 5

This would help try Installing the Nuget Package


Method 6

It’s work for me, Install the NewtonsoftJson package from NuGet “dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson –version 3.1.0” version 3.1.0 working for ASP.NET Core 3.0 and use the Following Code-

    .AddNewtonsoftJson(opt => {
        opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

Hope it’s Working Fine, Thanks.

Method 7

This worked for me, while using .Net Core 3:
click here

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x