I am using ASP.NET web api. To provide support for camel case for the properties that an end point returns, I have added this code:
//Support camel casing
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault();
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
This is working fine but I want to add an exception for one of the endpoints. Which will ensure when the data is returned from that end point, properties are not camel cased. How can I add this exception or a single endpoint?
It's not possible to make control if you are applying a global
camel case configuration
AFAK the only way to achieve this is by usingActionFilterAttribute
something like the followingif you try to call the first action the answer will like the follwing
and for the second action given that there is no filter you will get something like this
Note if you want to make it easy controlling camelCase over an entire controller, try to put your action that you want it to send back the answer in a not CamelCase in a controller apart but, for the rest apply this Filter on a controller level if you want. More you should delete the GlobalConfiguration to get this