MVC 6 Camel Case JSON

This means, if you have an application which uses both MVC controllers and Web API controllers then you need to apply any custom JSON serialization configurations twice or you should replace JavaScriptSerializer with JSON.NET.

// Sample
 public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
			services.AddMvc()
					.Configure<MvcOptions>(options => {

						var jsonOutputFormatter = new JsonOutputFormatter();
						jsonOutputFormatter.SerializerSettings.ContractResolver =
							new CamelCasePropertyNamesContractResolver();
						options.OutputFormatters.Insert(0, jsonOutputFormatter);
					});
        }

        public void Configure(IApplicationBuilder app)
        {
			app.UseMvc();
				
        }
    }
comments powered by Disqus