What is the optimum limit for URL length? 100, 200+

后端 未结 11 1863
抹茶落季
抹茶落季 2021-01-05 14:17

I have an ASP.Net 3.5 platform and windows 2003 server with all the updates.

There is a limit with .Net that it cannot handle more than 260 characters. Moreover if

相关标签:
11条回答
  • 2021-01-05 14:57

    Define "optimum" for your application.

    The HTTP standard has a limit (it depends on your application):

    The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

      Note: Servers ought to be cautious about depending on URI
      lengths above 255 bytes, because some older client or proxy
      implementations might not properly support these lengths.
    

    So the question is - what is the limit of your program, or what is the maximum resource identifier size your program needs to perform all its functionality?

    Your program should have a natural limit.

    If it doesn't you might as well stick it as 16k, as you don't have enough information to define the problem.

    -Adam

    0 讨论(0)
  • 2021-01-05 14:59

    There is no length limit specified by the W3C, but look here for practical limits

    http://www.boutell.com/newfaq/misc/urllength.html

    pick your own limit from that.

    0 讨论(0)
  • 2021-01-05 14:59

    More information is needed but for normal situations I would say try to keep it under 150 for sure. If for nothing else than pure ascetics, I hate when someone sends me a GI-NORMOUS link...

    Are you passing values through the query string? I assume that is why you asked, correct?

    0 讨论(0)
  • 2021-01-05 15:01

    This article gives the limits imposed by various browsers. It seems that IE limits the URL to 2083 chars, so you should probably stay under that if any of your users are on IE.

    0 讨论(0)
  • 2021-01-05 15:02

    When you say "Optimum", I think "Easily Accessible To Users", in which case, I think the shorter the URL, the better. I would think 20-30 characters maximum, in that case.

    0 讨论(0)
  • 2021-01-05 15:07

    Short ;-)

    The problem is that every web server and every browser has own ideas how long the maximum is. The RFC for the HTTP protocol gives no maximum length. IE limits the get to 2083 characters, the path itself may be at most 2,048 characters. However, this limit is not universal. Firefox claims to support at least up to 65,536, however some people verified that on some platforms even 100,000 characters work. Safari is above 80,000 (tested). Apache server on the other hand has a limit of 4,000. Microsofts Internet Information Server has one being 16,384 (but it is configurable).

    My recommendation is to stay below 2'000 characters in any case. This is not guaranteed to work with every browser in the world (especially not older ones), but it will work with all modern browsers. Further I recommend to use POST wherever possible (e.g. avoid using GET for FORM submits - if some users want to simulate a FORM submit via GET, make sure your application supports the desired parameters either via POST or via GET, but when you submit the page yourself via a button or JS, prefer POST over GET).

    0 讨论(0)
提交回复
热议问题