.net core MVC JSON 序列化屬性一直是小寫的解決方案
阿新 • • 發佈:2019-01-06
StartUp.cs 中設定(加上最後一行程式碼):
public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. //options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); //Session 儲存到記憶體 services.AddDistributedMemoryCache(); services.AddSession(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); }