Upgrade to Nuget package Telerik.UI.for.AspNet.Core 2022.2.510 now requires nuget package Microsoft.AspNetCore.Mvc.NewtonsoftJson

1 Answer 664 Views
General Discussions Grid
Martin
Top achievements
Rank 1
Martin asked on 27 May 2022, 03:56 PM

In Core 6 project setting following global JSON option to maintain property case (such as required for returning JSON result for Kendo Grids), since the Telerik upgrade, you now have to manually add Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget package

builder.Services.AddRazorPages().AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

or change to use System.Text.Json

builder.Services.AddRazorPages().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);

 

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 01 Jun 2022, 09:46 AM

Hello Martin,

The latest Kendo version is much more lightweight than the previous versions that have more dependencies.

Instead of using the Newtonsoft library and manually adding Microsoft.AspNetCore.Mvc.NewtonsoftJson package, I would recommend setting the serialization options for the application by using the following approach:

//Program.cs

var builder = WebApplication.CreateBuilder(args);

// Add framework services.
builder.Services
	.AddRazorPages()
    // Maintain property names during serialization. See:
    // https://github.com/aspnet/Announcements/issues/194
    .AddJsonOptions(options =>
                options.JsonSerializerOptions.PropertyNamingPolicy = null);

// Add Kendo UI services to the services container
builder.Services.AddKendo();

The JSON Serialization in .NET Core 6 is described in the article below:

https://docs.telerik.com/aspnet-core/installation/json-serialization#configure-json-serialization-in-aspnet-core-6-and-the-minimal-hosting-model

 

Regards,
Mihaela
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Martin
Top achievements
Rank 1
commented on 01 Jun 2022, 09:51 AM

Hi, many thanks for the reply and info, yes that is the route we chose to take

KR
Martin

Tags
General Discussions Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or