skip to Main Content

I need to send array as query parameter, I do it like this

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

After this I have string:

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

It can contain 100 elements and in this case I’m getting error:

enter image description here

Maybe I can do it in another way? Not by sending it inside query qtring.

2

Answers


  1. There is a limit on URL length on multiple levels (browsers, proxy servers, etc). You can change maxQueryString (*1) but I would not recommend it if you expect real users to use your system.

    It looks like downloads.aspx is your page. Put all those ids in temporary storage – (cache or database) and pass the key to this new entity in the request

    *1: https://blog.elmah.io/fix-max-url-and-query-string-length-with-web-config-and-iis/

    Login or Signup to reply.
  2. QueryString is not the way to pass an array because of the limits.
    If you have hands on the endpoint, you should consider sending your array in a POST Body.

    Regards

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search