在ASP.NET Core 2.0中找不到AddJsonOptions

编程入门 行业动态 更新时间:2024-10-25 18:27:25
本文介绍了在ASP.NET Core 2.0中找不到AddJsonOptions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将我的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

本文发布于:2023-11-08 11:06:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569201.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中找   NET   ASP   Core   AddJsonOptions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!