I have a problem with interworking MS WebAPI and ExtJS
ExtJS does an API call from
proxy : {
type : 'ajax',
noCache: false,
pageParam: false,
startParam: false,
limitParam: false,
extraParams: {
param1 : var1,
param2 : var2,
},
api: {
read : 'api/DataSource',
},
and my Web API application returns XML (I can see this in FireBug).
[System.Web.Http.AcceptVerbs("GET", "POST")]
[System.Web.Http.HttpGet]
public DataModel DataSource(int debug=0)
{
DataSource dataSource = new dataSource();
...
return dataSource
}
There is only one reason I can think of, why xml is returned: Firefox does not ask for application/json specifically on this ExtJS json call. If I change the default AcceptHeaders of Firefox to a more json-friendly one, JSON is returned.
As the user shall not have to change his browser settings, I see two solutions:
-> Tell the Javascript to ask for application/json.
-> Or tell MS to always return json.
I would prefer option 1, but I don't know whether or how I can change this?