Locally, my project works fine, but when I deploy to Azure using a web application, I get the following error on startup:
MissingMethodException: method not found: 'Newtonsoft.Json.JsonSerializerSettings Microsoft.AspNet.Mvc.Formatters.JsonOutputFormatter.get_SerializerSettings ()'. SmartAdmin.Startup. <> c.b__13_7 (MvcOptions options)
I tried this:
services.AddMvc(options => { options.Filters.Add(new UserPreferencesLoaderAtrribute()); var jsonFormatter = (JsonOutputFormatter)options.OutputFormatters.FirstOrDefault(f => f is JsonOutputFormatter); if (jsonFormatter != null) { jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); } });
And this:
services.AddMvc(options => { options.Filters.Add(new UserPreferencesLoaderAtrribute()); }).AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });
source share