JSON serializer Not Working After Upgrade To 3.6.2

假装没事ソ 提交于 2020-01-20 08:53:28

问题


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

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.

Is anybody knows how to fix it?

My code configuration is:

services.AddMvc().AddJsonOptions(x =>
            x.SerializerSettings.ContractResolver = new DefaultContractResolver());

Please let me know if you need more information.

Thank you in advance.


回答1:


Set it in Startup.cs > ConfigureServices() method

services.PostConfigure<MvcJsonOptions>(options =>
{
    options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});


来源:https://stackoverflow.com/questions/50986792/json-serializer-not-working-after-upgrade-to-3-6-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!