Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Passing array into query string

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

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

>Solution :

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/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading