Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to ask webapi for a specific content type

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)

like image 664
Omu Avatar asked Dec 16 '22 02:12

Omu


2 Answers

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.

like image 81
aKzenT Avatar answered Dec 28 '22 06:12

aKzenT


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.

like image 41
archil Avatar answered Dec 28 '22 05:12

archil