升级到3.6.2后,JSON序列化程序不起作用 [英] JSON serializer Not Working After Upgrade To 3.6.2
问题描述
我正在为我的一个应用程序使用ASP.NET Boilerplate.该应用程序在3.5.0版本的Abp上,模板是带有MVC的ASP.NET Core.我最近将其升级到3.6.2,升级很好,但是当我运行它时,所有AJAX调用现在都在CamelCase中返回JSON数据,而以前是在PascalCase中.我正在使用DefaultContractResolver进行JSON配置
I'm using ASP.NET Boilerplate for one of my application. The application was on 3.5.0 version of Abp and the template was ASP.NET Core with MVC. I recently upgraded it to 3.6.2 the upgrade was fine but when I run it all AJAX calls are returning JSON data in CamelCase now, previously it was in PascalCase. I'm using DefaultContractResolver for JSON configuration
我尝试了Google和StackOverflow的所有功能,但是没有运气.我下载了最新的ABP模板,并在那里添加了配置,但在那里也无法正常工作.似乎没有应用序列化程序设置.
I tried everything that was available in Google and StackOverflow, but no luck. I downloaded the latest ABP template and added configuration there as well but it is not working there as well. Seems like serializer settings are not applying.
有人知道如何解决吗?
我的代码配置是:
services.AddMvc().AddJsonOptions(x =>
x.SerializerSettings.ContractResolver = new DefaultContractResolver());
如果您需要更多信息,请告诉我.
Please let me know if you need more information.
谢谢.
推荐答案
在 Startup.cs > ConfigureServices()方法中设置
services.PostConfigure<MvcJsonOptions>(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});
这篇关于升级到3.6.2后,JSON序列化程序不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!