Search results
Suggest a FeaturePDF

How to use the Report Viewer and Designer with camel case serializer settings application

If you are using the camel serializer for our application, then will have a problem in processing API result with Report Viewer and Designer. So, you have to use the default resolver for using the Report Viewer and Designer.

  config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

You can refer the following code snippet to resolve to set the default serializer for Report Viewer and Designer Web API with 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
    {

    }