0

I make a request to a server which builds a URL and returns it to my client. The URL essentially can contain a huge query string at the end. I prompt the user to open a download window with this URL, but sometimes it gets cut off (IE). Any ideal solutions or workarounds?

xheyhenry
  • 1,049
  • 2
  • 13
  • 25
  • Queries should NEVER go in URLs in a plaintext state. Use a POST variable if you can. – Aaron Liske Oct 30 '15 at 22:19
  • What version of IE? Older versions limited urls to around 2k characters. There is nothing to be done about that—it's hard coded. – i_am_jorf Oct 30 '15 at 22:20
  • @AaronLiske what do you mean by this? I make a post request and that request builds a URL that I need – xheyhenry Oct 30 '15 at 22:23
  • @i_am_jorf IE 9 and 11 I believe. Currently testing on 11 and the path limit does seem to be ~2047 – xheyhenry Oct 30 '15 at 22:23
  • @xheyhenry, you said you have a URL that can contain a query. That should never happen, where the query is editable through a URL – Aaron Liske Oct 30 '15 at 22:24
  • Are you using AJAX to send the request to the server? You should use the `POST` method, and put the parameters in the `send()` call, rather than putting them in the URL. URLs are limited by most clients and servers. – Barmar Oct 30 '15 at 22:47
  • @Barmar yes I am using AJAX. I am already making a POST request to retrieve a built URL with some parameters, which is returned in its response – xheyhenry Oct 30 '15 at 22:55
  • But your problem is with sending those received parameters to another URL. You need to used `POST` there, as well. – Barmar Oct 30 '15 at 22:56
  • @Barmar hmm not sure I'm following. After I receive the URL I'm just calling a window.open(url) – xheyhenry Oct 30 '15 at 23:07
  • 1
    That's just not going to work if `url` is too long. See http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers and http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – Barmar Oct 30 '15 at 23:09
  • You need to come up with some other way of doing this, that doesn't require putting everything in the URL. Maybe use a session variable. – Barmar Oct 30 '15 at 23:09
  • @Barmar yeah that was my problem - the url became too long for IE browsers. I'll look into those - thank you. Also, would specifying an HTTP header location with the URL work? or would it still encounter max url lengths? – xheyhenry Oct 30 '15 at 23:12
  • @Barmar any suggestions on how to approach this? I've been stuck on this for a while. – xheyhenry Nov 02 '15 at 22:41
  • 1
    I can't think of any way to solve this. A web page that requires a really long query parameter is just misdesigned. – Barmar Nov 02 '15 at 22:49
  • @Barmar thanks. Still trying to wrap my head around how everything is working. This is also my first time working with query strings and I'm a novice when it comes to handling http requests – xheyhenry Nov 02 '15 at 23:15

0 Answers0