dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.16k stars 9.92k forks source link

Json not working with Kendo Ui Grid #18003

Closed davidbuckleyni closed 4 years ago

davidbuckleyni commented 4 years ago

I am having a major issue with .net core 3.1 and the kendo ui asp.net core grid supplied by telerik. This appears to be a .net issue and not Telerik.

As you see I have included my source of my startup.cs

` public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.Configure(Configuration);

        services.AddHttpClient("externalservice", c =>
        {
            // Assume this is an "external" service which requires an API KEY
            c.BaseAddress = new Uri("https://localhost:5001/");
        });
        services.AddSwaggerGen(c =>

        {
            c.SwaggerDoc("v1", new OpenApiInfo { Title = "Api For RoundTable A Complete ERP for warehouse managment", Version = "v1" });
        });

        services
            .AddControllersWithViews()
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
            // Maintain property names during serialization. See:
            // https://github.com/aspnet/Announcements/issues/194
            .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
    }`

My Api Call

` public async Task<List> GetStockFromApi(){ List _result = new List();

        var uri = new Uri(string.Format(Constants.GetALlStock, string.Empty));

        var response = await _httpClient.GetAsync(uri);
        if (response.IsSuccessStatusCode)
        {
            var byteArray = await response.Content.ReadAsByteArrayAsync(); 

            var content = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);
            _result = JsonConvert.DeserializeObject<List<Stock>>(content);
        }

        return _result.ToList();
    }

` I have used postman to check my json response and noticed that it is still coming in lower case. However, the data objects deserialize ok but I am having real trouble in getting my kendo ui grid to bind. This approach worked fine in .net 2.2 and .net core 1 image

Visual Studio Copy System info details

Microsoft Visual Studio Community 2019 Preview Version 16.5.0 Preview 1.0 VisualStudio.16.Preview/16.5.0-pre.1.0+29521.150 Microsoft .NET Framework Version 4.8.04084

Installed Version: Community

Visual C++ 2019 00435-60000-00000-AA238 Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019 16.5.126.18061 ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2012 16.5.126.18061 For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2019 16.5.126.18061 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.5.126.18061 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.5.126.18061 Azure Functions and Web Jobs Tools

BusinessObjectEditor 1.0 Information about my package

C# Tools 3.5.0-beta1-19571-01+fb3f812a3e4b7534bef784fa2df1c21d1f67864d C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

ConvertToDevExtremeCommand Extension 1.0 ConvertToDevExtremeCommand Visual Studio Extension Detailed Info

Cookiecutter 16.5.19318.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Create Stored Procedures 1.0 Create stored procedures

CreateCrud Extension 1.0 CreateCrud Visual Studio Extension Detailed Info

DevExpress Reporting Extension 1.0 A Visual Studio extension that invokes the Report Designer editor for report definition REPX files.

DevExpress.DeploymentTool 1.0 A useful tool for deploying DevExpress assemblies.

DevExpress.ExpressApp.Design.DynamicPackage 1.0 DevExpress VSIX Package

DevExpress.ExpressApp.DesignPackage 1.0 DevExpress VSIX Package

DevExpress.Win.LayoutAssistant Extension 1.0 DevExpress.Win.LayoutAssistant Visual Studio Extension Detailed Info

Extensibility Message Bus 1.2.0 (d16-2@8b56e20) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

JetBrains ReSharper Ultimate 2019.2.3 Build 192.0.20191016.60459 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2019 JetBrains, Inc.

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21108.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.3+g9c91cdec24 Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 16.5.505 (ecce84f) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.5.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

Python 16.5.19318.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Conda support 16.5.19318.1 Conda support for Python projects.

Python - Django support 16.5.19318.1 Provides templates and integration for the Django web framework.

Python - IronPython support 16.5.19318.1 Provides templates and integration for IronPython-based projects.

Python - Profiling support 16.5.19318.1 Profiling support for Python projects.

Python - VC Project Support 16.1.19129.1 Provides support for launching C++ projects with Python debugging enabled.

SQL Server Data Tools 16.0.61911.21070 Microsoft SQL Server Data Tools

Telerik ASP.NET Core VSExtensions 2019.3.1106.1 Progress® Telerik® UI for ASP.NET Core Visual Studio extensions

Telerik ASP.NET MVC VSExtensions 2019.3.1106.1 Progress® Telerik® UI for ASP.NET MVC Visual Studio extensions

Telerik WinForms VSExtensions 2019.3.1106.1 Progress® Telerik® UI for WinForms Visual Studio extensions

Telerik WPF VSExtensions 2019.3.1106.1 Progress® Telerik® UI for WPF Visual Studio extensions

Telerik Xamarin VSExtensions 2019.3.1118.1 Progress® Telerik® UI for Xamarin Visual Studio extensions

TypeScript Tools 16.0.11113.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.5.0-beta1-19571-01+fb3f812a3e4b7534bef784fa2df1c21d1f67864d Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6 16.5.0-beta.19556.3+c2b6d5980a7f64dd4e46448b9b4f5d96eb415aeb Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info

Xamarin 16.5.000.322 (d16-5@4d76f33) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.5.0.93 (remotes/origin/d16-5@2c7bbb76b) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.5.31 (91cfcf5) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 10.2.0.16 (d16-5/48f0fe7) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 062f0ab Java.Interop: xamarin/java.interop/d16-5@47f47bc ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

Xamarin.iOS and Xamarin.Mac SDK 13.14.0.6 (bde12ca) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

WiredUK commented 4 years ago

This is an announcements repo, not for you to open issues. Next time, please read the repository readme.

hishamco commented 4 years ago

As @WiredUK said this is an announcement repo, @davidbuckleyni please move your issue to https://www.github.com/aspnet/aspnetcore

p-m-j commented 4 years ago

If you can deserialize just fine, how is this a .Net issue instead of a kendo.ui issue or just plain user error?

kakone commented 4 years ago

Add this line in your Startup.cs file : .AddJsonOptions(opt => opt.JsonSerializerOptions.PropertyNamingPolicy = null)