将数组传递给查询字符串
Passing array into query string
我需要发送数组作为查询参数,我是这样做的
StringBuilder Ids = new StringBuilder();
for (int i = 0; i < array.Count; i++)
{
Ids.Append(String.Format("&id[{0}]={1}", i, items[i].ID));
}
ifrDocuments.Attributes.Add("src", "Download.aspx?arrayCount=" + array.Count + Ids);
在此之后我有字符串:
Download.aspx?arrayCount=8&id[0]=106066&id[1]=106065&id[2]=106007&id[3]=105284&id[4]=105283&id[5]=105235&id[6]=105070&id[7]=103671
它可以包含 100 个元素,在这种情况下我收到错误消息:
enter image description here
也许我可以换一种方式?不是通过在查询 qtring 中发送它。
多个级别(浏览器、代理服务器等)的 URL 长度有限制。您可以更改 maxQueryString (*1),但如果您希望真正的用户使用您的系统,我不会推荐它。
看起来 downloads.aspx 是您的页面。将所有这些 id 放入临时存储 - (缓存或数据库)并将密钥传递给请求中的这个新实体
*1: https://blog.elmah.io/fix-max-url-and-query-string-length-with-web-config-and-iis/
由于限制,QueryString 不是传递数组的方式。
如果你有端点,你应该考虑在 POST Body 中发送你的数组。
此致
我需要发送数组作为查询参数,我是这样做的
StringBuilder Ids = new StringBuilder();
for (int i = 0; i < array.Count; i++)
{
Ids.Append(String.Format("&id[{0}]={1}", i, items[i].ID));
}
ifrDocuments.Attributes.Add("src", "Download.aspx?arrayCount=" + array.Count + Ids);
在此之后我有字符串:
Download.aspx?arrayCount=8&id[0]=106066&id[1]=106065&id[2]=106007&id[3]=105284&id[4]=105283&id[5]=105235&id[6]=105070&id[7]=103671
它可以包含 100 个元素,在这种情况下我收到错误消息:
enter image description here
也许我可以换一种方式?不是通过在查询 qtring 中发送它。
多个级别(浏览器、代理服务器等)的 URL 长度有限制。您可以更改 maxQueryString (*1),但如果您希望真正的用户使用您的系统,我不会推荐它。
看起来 downloads.aspx 是您的页面。将所有这些 id 放入临时存储 - (缓存或数据库)并将密钥传递给请求中的这个新实体
*1: https://blog.elmah.io/fix-max-url-and-query-string-length-with-web-config-and-iis/
由于限制,QueryString 不是传递数组的方式。 如果你有端点,你应该考虑在 POST Body 中发送你的数组。
此致