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

霸气de小男生 提交于 2019-12-24 00:36:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!