问题
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