Interviews - C# Corner

Sanwar Ranwa
How to make sure that Web API returns data in JSON format only?
By Sanwar Ranwa in .NET Core onJul 18 2018
  • Uzma Khan
    Oct, 2018 1

    In WebApiConfig.cs file in solution add mentioned line as shown in examplepublic 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")); }

    • 2
  • Vladimir Lapenkov
    Feb, 2019 6


    • 0

Most Popular Companies

Most Popular Job Functions