Open WebApiConfig.cs file in solution and add mentioned line in it as shown in example.
config.Formatters.Remove(config.Formatters.XmlFormatter);
Or
Orvar formatters = GlobalConfiguration.Configuration.Formatters;formatters.Remove(formatters.XmlFormatter);
config.Formatters.Remove(config.Formatters.XmlFormatter);
Or
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//To produce JSON format add this line of code
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(newMediaTypeHeaderValue("text/html"));
}
No comments:
Post a Comment