JSON properties now lower case on swap from ASP .Net Core 1.0.0-rc2-final to 1.0.0

MVC now serializes JSON with camel case names by default

Use this code to avoid camel case names by default

  services.AddMvc()
        .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

Source: https://github.com/aspnet/Announcements/issues/194


In case you found this from Google and looking for a solution for Core 3.

Core 3 uses System.Text.Json, which by default does not preserve the case. As mentioned with this GitHub issue, setting the PropertyNamingPolicy to null will fix the problem.

public void ConfigureServices(IServiceCollection services)
{
...
    services.AddControllers()
            .AddJsonOptions(opts => opts.JsonSerializerOptions.PropertyNamingPolicy = null);

and if you don't want to change the global settings, for one action only it's like this:

return Json(obj, new JsonSerializerOptions { PropertyNamingPolicy = null });

You can change the behavior like this:

services
    .AddMvc()
    .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

See the announcement here: https://github.com/aspnet/Announcements/issues/194