Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
323 views
Welcome To Ask or Share your Answers For Others

1 Answer

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
  • check that you have using Microsoft.Extensions.DependencyInjection;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...