I'm migrating my ASP.NET 1.1 project to 2.0:
Inside the Setup
class, under the Configure
method override I have:
services.AddMvc()
.AddJsonOptions(options =>
options.SerializerSettings.Converters.Add(new StringEnumConverter())
);
The AddJsonOptions
method is missing.
What happened to it? How can I get the same functionality?
AddJsonOptions
is defined in Microsoft.AspNetCore.Mvc.Formatters.Json nuget package.If your project has a dependency to
Microsoft.AspNetCore.All
metapackage (in your .csproj:<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0"/>
) then you already have it. Otherwise, you may need to add that package directly.After that do:
dotnet restore
using Microsoft.Extensions.DependencyInjection;