title: UriPathExtensionMapping Web API 2
body: <p>I am using Web API 2.1, I have successfully used CORS and UriPathExtensionMapping. But i would like to access my api resources as query string parameters as well i.e. </p>
  
  <p><a href="http://example.com/test/api/Employee" rel="nofollow">http://example.com/test/api/Employee</a></p>
  
  <p><a href="http://example.com/test/api/Employee?id=10" rel="nofollow">http://example.com/test/api/Employee?id=10</a></p>
  
  <p><a href="http://example.com/test/api/Employee.json" rel="nofollow">http://example.com/test/api/Employee.json</a></p>
  
  <p><a href="http://example.com/test/api/Employee.xml" rel="nofollow">http://example.com/test/api/Employee.xml</a></p>
  
  <p><a href="http://example.com/test/api/Employee.json?id=10" rel="nofollow">http://example.com/test/api/Employee.json?id=10</a></p>
  
  <p><a href="http://example.com/test/api/Employee.xml?id=10&amp;name=someone" rel="nofollow">http://example.com/test/api/Employee.xml?id=10&amp;name=someone</a></p>
  
  <p><a href="http://example.com/test/api/Employee.json?id=10&amp;name=someone" rel="nofollow">http://example.com/test/api/Employee.json?id=10&amp;name=someone</a></p>
  
  <p>All above mentioned resources is how i want them to use. I am able to use 1,2,3,4 however after that with extension and query string it does not seem to work.</p>
  
  <p>Below is my WebApiConfig.cs code.</p>
  
  <pre><code>config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}",
              defaults: new { }
          );
  
          config.Routes.MapHttpRoute(
              name: "ApiUriPathExtension",
              routeTemplate: "api/{controller}.{ext}",
              defaults: new { ext = RouteParameter.Optional }
          );
  
          var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t =&gt; t.MediaType == "application/xml");
          config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
  
          config.Formatters.XmlFormatter.AddUriPathExtensionMapping("xml", "text/xml");
          config.Formatters.JsonFormatter.AddUriPathExtensionMapping("json", "application/json");
  </code></pre>
  
  <p>What am i missing, any help is greatly appreciated.</p>