OData网址长度限制 [英] OData Url Length Limitations

查看:107
本文介绍了OData网址长度限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览器对URL的长度有限制. IE的限制是网址长度不能超过2K个字符.

Browsers have limitation on the length of the URLs. IE has limitation that Url length should not exceed 2K characters.

当我形成一个$ filter等于查询时,我可以与多个输入值进行比较.在这种情况下,网址的长度将超过2K.

When I form a $filter equals query, I could compare with multiple input values. In such a case the length of the Url would exceed 2K.

OData是否对Url的长度设置任何限制?

Does OData sets any limits on the length of the Url?

谢谢

推荐答案

OData本身并不限制Url的长度,但是正如您指出的,大多数客户端和服务器都可以.因此通常最好不要产生太长的URL.

OData itself doesn't limit the length of the Url, but as you noted most clients and servers do. So usually it's a good practive to not produce URLs too long.

您提到的问题(实现Contains运算符或类似的操作)有两种可能的解决方法:

The problem you refer to (implementing the Contains operator, or something similar) has two possible workarounds:

1)使用服务操作为您处理此类查询.您可以传递编码为字符串或类似形式的多个输入值,或者服务操作无论如何都可以预先知道这些.

1) Use service operation to handle such query for you. You can possibly pass the multiple input values encoded as a string or something like that, or maybe the service operation knows these up front anyway.

2)使用长$ filter,但以$ batch请求发送请求.好处是Url的限制要大得多,您几乎不可能达到它.缺点是,即使您尝试执行GET请求,由于$ batch会以POST请求的形式在网络上传播,因此不会被缓存.

2) Use the long $filter, but send the request in a $batch request. The advantage is that the limit on the Url is much bigger and it's very unlikely you will hit it. The disadvantage is that even though you're trying to execute a GET request, due to the $batch it travels as POST request over the web and thus it won't be cached.

这篇关于OData网址长度限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆