[英]Migrate from /net core 2.1 to .net core 3.1
I am getting an error while migrating from .net core 2.1 to .net core 3.1从 .net core 2.1 迁移到 .net core 3.1 时出现错误
Error: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher.错误:面向 .NET Core 3.0 或更高版本时,不支持 Microsoft.AspNetCore.All 包。 A FrameworkReference to Microsoft.AspNetCore.The app should be used instead and will be implicitly included by Microsoft.NET.Sdk.Web.应使用对 Microsoft.AspNetCore 的 FrameworkReference。应改用该应用程序,并将隐式包含在 Microsoft.NET.Sdk.Web 中。
i am getting issue with services.AddMvc(options => { options.Filters.Add(new AuthorizeFilter("default")); }).AddJsonOptions(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize) 'JsonOptions' does not contain a definition for 'SerializerSettings'我遇到了 services.AddMvc(options => { options.Filters.Add(new AuthorizeFilter("default")); }).AddJsonOptions(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize) 的问题“JsonOptions”不包含“SerializerSettings”的定义
For asp.net core 3.0+,you need to install the package Microsoft.AspNetCore.Mvc.NewtonsoftJson for your version firstly,then replace对于asp.net core 3.0+,你需要先为你的版本安装包Microsoft.AspNetCore.Mvc.NewtonsoftJson ,然后替换
services.AddMvc()
.AddJsonOptions(
options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize);
with和
services.AddControllersWithViews()
.AddNewtonsoftJson(options =>
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize);
Refer to https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#use-newtonsoftjson-in-an-aspnet-core-30-mvc-project请参阅https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#use-newtonsoftjson-in-an-aspnet-core -30-mvc-项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.