C# Web API Either XML or JSON based on GET request
问题 My config.Routes was set to: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); With this I could use: localhost:port/api/products - get a full list of products localhost:port/api/products/# - get a single product with the given id Based on the browser I was getting a different format (you get XML format in FireFox and Google Chrome as default, and JSON in Internet Explorer). I mostly need JSON, so at first