Can you elaborate a bit more about what you want to accomplish. Normally I would suggest using an API controller if you want json data, which can format it automatically if you set the default formatter to a json formatter:
public class ApiConfigurationComponent : IComponent
{
public void Initialize()
{
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter
{
SerializerSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}
});
}
Perhaps a surface controller(https://our.umbraco.com/documentation/reference/routing/surface-controllers)? Instead of returning an ActionResult, you could return a JSONResult. Also assuming that the data is for public consumption.
How to get Json from umbraco content
Hi Team,
Can you please suggest the ways of getting the Json instead of front end layout (preview) when we click on any content?
Can you elaborate a bit more about what you want to accomplish. Normally I would suggest using an API controller if you want json data, which can format it automatically if you set the default formatter to a json formatter:
Perhaps a surface controller(https://our.umbraco.com/documentation/reference/routing/surface-controllers)? Instead of returning an ActionResult, you could return a JSONResult. Also assuming that the data is for public consumption.
is working on a reply...