How to use the Report Viewer and Designer with camel case serializer settings application
To use the Bold Reports® Report Viewer and Report Designer in an application with camel case serializer settings, use the default resolver for their Web API. With the camel case serializer, the Report Viewer and Designer have a problem processing the API result. An application has this problem when it uses the following setting.
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();The following code sets the default serializer for the Report Viewer and Designer Web API in ASP.NET MVC.
public class DefaultCaseControllerConfigAttribute : Attribute, System.Web.Http.Controllers.IControllerConfiguration
{
public void Initialize(System.Web.Http.Controllers.HttpControllerSettings controllerSettings, System.Web.Http.Controllers.HttpControllerDescriptor controllerDescriptor)
{
var formats = controllerSettings.Formatters.OfType<System.Net.Http.Formatting.JsonMediaTypeFormatter>().ToList();
foreach (var format in formats)
{
controllerSettings.Formatters.Remove(format);
}
var formatter = new System.Net.Http.Formatting.JsonMediaTypeFormatter
{
SerializerSettings = { ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver() }
};
controllerSettings.Formatters.Add(formatter);
}
}
[DefaultCaseControllerConfigAttribute]
public class RreportApiController : ApiController, IReportController
{
}