Reputation: 71258
as I understood from ASP.net MVC 4 Release notes, is that it has Content Negotiation, and that it will return the content type requested by the client
how is the client asking for a specific content ?
(in my case would be flash asking for XML, using AMF)
Upvotes: 4
Views: 10386
Reputation: 1382
By default web api use json, son you dont have to do anything special to receive json. You see xml in chrome because the browser convert the response to xml. You need to use Fiddler to see the exact respones of your web api service. The web api gives you two flavors to receive data, json and xml and can be changed in the response header. Use the following,
use one of this
Content-Type: application/json (for json)
or
Content-Type: application/xml (for xml)
in Fiddler go to the composer and write one of this in the response header and make some test.
Upvotes: 0
Reputation: 7915
Like vansimke said, you just set the content type you need.
In the ActionScript client, it should be as easy as:
request.setHeader("Accept", "application/xml");
The server then respons with the header "Content-Type".
response.setHeader("Content-Type", "application/xml");
Hope that helps!
Edit: headers wrong.
Upvotes: 10
Reputation: 39501
This is just the guess, but I think Accept header should do the trick
The Accept request-header field can be used to specify certain media types which are acceptable for the response. Accept headers can be used to indicate that the request is specifically limited to a small set of desired types, as in the case of a request for an in-line image.
The main differene between Accept and Content-Type is that Accept header specifies type expected in response, when Content-Type specifies actual type of response. Therefore, when requesting, you should use Accept.
Upvotes: 2
Reputation: 974
Set the 'Content-Type: ' header. e.g. Content-Type: application/xml requests xml from the service.
Upvotes: 0