problem:
Problems encountered when requesting dynamic binding data using ajax in asp.net core in:
Background data field is returned to the first letter of the definition of capital, the returned data is no problem; but at the front desk to get the data, the field has become a lowercase first letter
At this time, with the first letter capitalized to receive the data field definition displays undefined, because in the json asp.net core camelCased default serialization processing field, the first letter lowercase , the data is not acquired.
Solution:
Configuration, DefaultContractResolver () is outputted in class ConfigureServices Startup () method, consistent with the background defined returned json
public void ConfigureServices(IServiceCollection services) { ... services.AddMvc().AddJsonOptions(opt => { opt.SerializerSettings.ContractResolver = new new Newtonsoft.Json.Serialization.DefaultContractResolver (); // JSON case of the string is outputted }); }
At this same initials json string field size defined background
Reference: ASP.NET Core return json data initials sensitive issues