John
John

Reputation: 418

Why does the Breeze Web API implementation respond to metadata requests with a string instead of a JSON object?

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;
 }

Upvotes: 2

Views: 333

Answers (1)

Jay Traband
Jay Traband

Reputation: 17052

As of v 1.2.7, the BreezeController attribute now does this automatically.... and thanks for the idea.

Upvotes: 1

Related Questions