问题
Is there any reason that the Breeze Web API implementation of the response to any metadata requests returns a string instead of a JSON object?
Sending metadata as text adds a lot of overhead over the network (due " encoding) and on clientside due manual JSON.parse.
I think that your controller can simply return the Metadata as JSON by specifying the contentType header: i.e.
[HttpGet]
public HttpResponseMessage Metadata()
{
var result = new HttpResponseMessage { Content = new StringContent(_contextProvider.Metadata())};
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return result;
}
回答1:
As of v 1.2.7, the BreezeController attribute now does this automatically.... and thanks for the idea.
来源:https://stackoverflow.com/questions/15507497/why-does-the-breeze-web-api-implementation-respond-to-metadata-requests-with-a-s