我将我的ASP.NET 1.1项目迁移到2.0:
I'm migrating my ASP.NET 1.1 project to 2.0:
在 Setup 类内, Configure 方法覆盖了我
Inside the Setup class, under the Configure method override I have:
services.AddMvc() .AddJsonOptions(options => options.SerializerSettings.Converters.Add(new StringEnumConverter()) );缺少 AddJsonOptions 方法。
发生了什么事?如何获得相同的功能?
What happened to it? How can I get the same functionality?
推荐答案AddJsonOptions 在 Microsoft.AspNetCore.Mvc.Formatters.Json nuget程序包。
AddJsonOptions is defined in Microsoft.AspNetCore.Mvc.Formatters.Json nuget package.
如果您的项目依赖于 Microsoft.AspNetCore.All 元包(在您的.csproj中:< PackageReference Include = Microsoft.AspNetCore.All Version = 2.0.0 /> ),那么您已经拥有了它。否则,您可能需要直接添加该软件包。
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恢复
- 使用Microsoft.Extensions.DependencyInjection检查您是否具有;
- dotnet restore
- check that you have using Microsoft.Extensions.DependencyInjection;
更多推荐
在ASP.NET Core 2.0中找不到AddJsonOptions
发布评论