routes.MapHttpRoute(
name:
"DefaultApi"
,
routeTemplate:
"api/{controller}/{id}"
defaults:
new
{ id = RouteParameter.Optional }
);
curl -H
"Accept: application/json"
-H
"Content-Type: application/json"
-X GET
"http://localhost/:13938/api/values"
[
"value1"
"value2"
]
"Accept: application/xml"
"Content-Type: application/xml"
<?
xml
version
=
"1.0"
encoding
"utf-8"
?>
<
ArrayOfString
xmlns:xsi
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd
"http://www.w3.org/2001/XMLSchema"
>
string
>value1</
>value2</
</
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(
QueryStringMapping(
"type"
"json"
MediaTypeHeaderValue(
"application/json"
)));
GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add(
"xml"
"application/xml"
Richard Mueller edited Revision 5. Comment: Removed (en-US) from title, added tags
Filip Ekberg edited Revision 4. Comment: formatting
FZB edited Revision 3. Comment: formating
Tord G.Nordahl edited Revision 2. Comment: corrected some spelling, and layout
Horizon_Net edited Original. Comment: added language tags
Great article Filip Ekberg!