Solve ASP.NET CORE return Json data field name in lowercase first letter of the default problem

Solution:

Configuration, DefaultContractResolver () is outputted in class ConfigureServices Startup () method, consistent with the background defined returned json

Code:

public void ConfigureServices(IServiceCollection services)
{
     services.AddMvc().AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();//json字符串原样输出
            });
}

 

Published 105 original articles · won praise 17 · views 110 000 +

Guess you like

Origin blog.csdn.net/qq_38890412/article/details/103793399