asp.net - Google Protocol Buffers 或类似的 .net/javascript

标签 asp.net javascript protocol-buffers

我们目前正在使用 Ajax 调用 .net 网络服务,然后将 Json 对象返回给客户端。其中一些 Json 对象非常庞大(> 500k 未压缩)。我们听说过有关 Google Protocol Buffers 的一些好消息,并且一直在进行试验。

到目前为止,我们已经很幸运地在服务器上使用最常见的 .net 版本 - “protobuf-net” 进行了序列化。我们在客户端反序列化时运气不佳。我们尝试使用似乎是唯一的 javascript 反序列化程序 protobuf.js。我们发现它不容易使用,示例或文档很少,而且它似乎无法处理字符串和整数以外的数据类型。

在这一点上,似乎会有一个经过验证的、定义明确的解决方案,用于 .net 和 Web 客户端之间的二进制数据序列化/反序列化。也许我们遗漏了一些明显的东西。

我们的要求是来自客户端的 Ajax 调用,以及服务器上的 .net Web 服务方法(.asmx 或 WCF)。

如有任何意见和建议,我们将不胜感激。

最佳答案

如果客户端是 javascript,我想你会很吃力。有(如您所述)有限 javascript 覆盖范围,但我不确定它是否会给您带来很多好处。至quote from Kenton Varda (真正了解protobuf的人):

One problem with javascript and protobuf is that you need a lot of support code to parse the messages. Unless you end up sending quite a lot of stuff back and forth, making the user download a JS protobuf codec library may be a net loss. It may be better to use JSON or XML because browsers already have built-in support for those.

That said, I think various people inside google have been playing with javascript + protocol buffers for awhile and if we end up with anything that works well enough, we'll release it.

所以也许 future 还有希望。现在我会坚持使用 json + deflate,或者如果您的场景允许,您也许可以使用嵌入在客户端中的 Silverlight 小程序? protobuf-net 将在 Silverlight 中运行。

关于asp.net - Google Protocol Buffers 或类似的 .net/javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1131504/

相关文章:

asp.net - 即使数据不敏感,我是否需要在用户登录后保持 HTTPS (SSL) 状态?

javascript - 当两者具有相同的名称时,javascript 类方法如何知道调用函数或方法?

java - Protobuf 生成器 : set string field without memory allocation

css - 尝试在.NET中使用CSSMinify类

c# - 如何在 ASP.NET MVC 5 Controller 中返回 http 中的字符串?

javascript - Sharepoint 中的 onready 事件

javascript - 头上有重复的样式和很多 <style> 元素

c# - Google Protocol Buffer 与 JSON : C++ to C# communication

rust - 如何在 Rust 中使用 prost 生成代码?

c# - 如何使用 TextChanged 事件过滤 gridview?