0

I've an action that I've to put in a GET request.

The URL is build live, and looks like this:

https://my-domain.com/MyController/MyAction?MyParameter=8259%2C8318%2C8201%2C8188%2C7155%2C6894%2C8221%2C8187%2C7030%2C8214%2C7489%2C8145%2C8223%2C8208%2C8273%2C8257%2C8292%2C6931%2C7072%2C7007%2C8195%2C8235%2C7493%2C7525%2C7492%2C8262%2C7491%2C7013%2C8157%2C7180%2C7181%2C7182%2C7183%2C7421%2C7422%2C7500%2C7501%2C8238%2C8239%2C8240%2C8241%2C7710%2C7711%2C7712%2C7713%2C8068%2C8432%2C7358%2C7008%2C8135%2C8307%2C8163%2C8164%2C8132%2C8182%2C8183%2C8081%2C8083%2C8109%2C8110%2C7681%2C7682%2C7683%2C7593%2C7594%2C7595%2C7546%2C7547%2C7548%2C7577%2C7578%2C7581%2C8300%2C8301%2C8302%2C8282%2C8283%2C8284%2C8311%2C8312%2C8313%2C8217%2C8218%2C8244%2C8245%2C8479%2C8482%2C8398%2C8399%2C8400%2C8401%2C8404%2C8407%2C8392%2C8394%2C6959%2C6960%2C6961%2C7041%2C7042%2C7043%2C8227%2C8228%2C8229%2C7638%2C7708%2C7118%2C8288%2C6897%2C6898%2C6899%2C6900%2C6901%2C6902%2C6842%2C6843%2C6844%2C6845%2C6846%2C6847%2C7361%2C7362%2C7363%2C7364%2C7365%2C7366%2C8165%2C8166%2C8167%2C8168%2C8169%2C8170%2C8247%2C8248%2C8249%2C8250%2C8251%2C8252%2C8099%2C8100%2C6903%2C6904%2C6905%2C6906%2C6907%2C6908%2C7704%2C8291%2C8253%2C7709%2C8277%2C7372%2C7282%2C7552%2C8205%2C7341%2C8264%2C7384%2C7701%2C7432%2C7625%2C7169%2C6912%2C8095%2C7481%2C8452%2C7062%2C7664%2C8088%2C8209%2C8278%2C6986%2C6978%2C7128%2C7440%2C6987%2C8224%2C8225%2C8178%2C8179%2C6889%2C6890%2C8191%2C8093%2C8230%2C7317%2C6895%2C8211%2C8226%2C8285%2C7266%2C7321%2C7445%2C7672%2C7453%2C7476%2C7533%2C6967%2C8054%2C7377%2C7188%2C8323%2C8105%2C7276%2C8202%2C8072%2C7689%2C8434%2C7075%2C7257%2C7379%2C6864%2C7570%2C8146%2C8147%2C8148%2C8149%2C7018%2C7019%2C7020%2C7021%2C8031%2C7044%2C7278%2C7486%2C8409%2C7707%2C8438%2C7378%2C7265%2C7176%2C7199%2C7706%2C7632%2C6998%2C7584%2C8171%2C7399%2C7125%2C6836%2C7535%2C7528%2C6968%2C7327%2C8319%2C8098%2C7543%2C6852%2C7103%2C6882%2C8426%2C8114%2C6957%2C6952%2C7527%2C6956%2C6953%2C8196%2C6989%2C7246%2C8272%2C8320%2C8324%2C6979%2C8315%2C8293%2C8294%2C8322%2C8204%2C7203%2C7326%2C7355%2C7087%2C7009%2C7498%2C7700%2C8113%2C8274%2C8325%2C8321%2C8116%2C7211%2C7252%2C7332%2C7023%2C7074%2C6977%2C7603%2C8096%2C7063%2C7014%2C7416%2C8190%2C8310%2C7032%2C7129%2C7136%2C7131%2C7187%2C7170%2C7159%2C7532%2C7651%2C7262%2C7670%2C7402%2C7403%2C7245%2C7235%2C7601%2C7316%2C7545%2C7343%2C7376%2C7665%2C7688%2C7374%2C7375%2C8041%2C7404%2C7409%2C7419%2C8422%2C7461%2C7438%2C7443%2C7487%2C7464%2C7515%2C7514%2C7512%2C7523%2C7598%2C8176%2C7544%2C7620%2C7652%2C7690%2C8330%2C8335%2C8418%2C8417%2C8421%2C8442%2C8458%2C8492%2C8457%2C8474%2C8483

And I get a 404 error.

If I replace the %2C by the original ,I got the same problem, just with a little more parameters.

If I make the same request with less parameters, it works.

I already have this:

<system.web>
    <httpRuntime maxUrlLength="2097151" maxQueryStringLength="2097151" relaxedUrlToFileSystemMapping="true"/>
</system.web>

Because previously I was having telling me that I was having a maxQueryStringLength set too big.

J4N
  • 19,480
  • 39
  • 187
  • 340

2 Answers2

3

No matter how large you set the maxQueryStringLength, there's a limit in the browsers. For example some browsers support a request length of only 2048 characters. Yours is longer (2440 characters). The only thing you could do is to use POST instead of GET to send such large data because POST requests doesn't have such limitation. So you generate an HTML <form> element with method="post" and action pointing to the url and a hidden field inside it containing this data and then submit this form.

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • See my answer. It's just unthinkable for me to say that all the internet is limited to 2048 chars. Hopefully it's not the problem. And I've just 10+ reason to use GET instead of POST in this case, I wasn't asking how to use POST instead of GET. Anyway, thank you for trying to help – J4N Sep 24 '12 at 12:18
  • 1
    I never said that all the internet is limited to 2048 chars. Where did you read this in my answer? I said that **some browsers** have such limit and if you continue to use GET for sending large data your site will eventually break under some browsers. And I suggested you to use POST as a workaround instead. I don't see where I did wrong in my answer. Anyway I guess you know it better. Just don't get surprised if you get sporadic errors in your production event log that you cannot reproduce in your DEV environment because the browse browser that you are using to test doesn't have such limit. – Darin Dimitrov Sep 24 '12 at 12:19
2

In fact, I was blocked by an IIS limit: the maxUrl size and max query size(which is measured in octet:

  <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxUrl="1048576" maxQueryString="1048576" />
        </requestFiltering>
      </security>
  </system.webServer>

This resolved my problem

J4N
  • 19,480
  • 39
  • 187
  • 340