URL too long - bad request [Answered]RSS

13 replies

Last post Sep 07, 2011 01:35 PM by badripennati

  • URL too long - bad request

    Aug 12, 2009 05:50 AM|m@t|LINK

    Hello,

    I have sometimes a problem with a website when the url is too long. The error "bad request" is displayed.

    URL example :

    http://www.domain.com/uoQ76Kb2QL5hzaVOSAKWeX0W9LfDLqphmRXpsfHN8tgF5lCsfTxlOVWY8vFwzhsRzoNYKhUIOTc5TnUlT0vpdQflPyk2nh7vurXOj60cDnkG3nsrXMhFCsPjhcZAic2jKpF9F9TYRYQwJo81IMi6gY01RK3ZcNl8WGfqcvoZ702UIdetvR7kiaqo1czwSJCMjRFdG6EgMzgXrwE8DYMz4fWqoa1F1c1qwTCBk3yOcmGTbxsPSJK5QRyNea9IFLrBTjfE7ZlN2vZiI7adcDYJef.htm

    If I remove some characters, the error disappeared.

    The website is installed on WS 2003 and IIS 6.0 and there isn't any error logued in C:\WINDOWS\system32\LogFiles\HTTPERR\httperr.log.

    I tried to modify the registry :

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\MaxFieldLength     (32768)

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\MaxRequestBytes   (32768)

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\UrlSegmentMaxLength   (0)



    I restarted the IIS service administration and the machine but the issue has not been fixed.

    I precise that urlScan is not installed on the server.

    Have you got any idea to fix the problem ?

    Thanks

  • Re: URL too long - bad request

    Aug 12, 2009 08:02 AM|jeff@zina.com|LINK

    m@t

    Have you got any idea to fix the problem ?

    Stop using long URLs.

    Jeff

    Have you Binged a solution before posting?
  • Re: URL too long - bad request

    Aug 12, 2009 08:12 AM|m@t|LINK

     Unfortunately, i can't.

     Is there any way to fix it ?

     

  • Re: URL too long - bad request

    Aug 12, 2009 02:20 PM|tomkmvp|LINK

    No.  There is a limit on the length of the URL.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: URL too long - bad request

    Aug 12, 2009 04:21 PM|Paul Lynch|LINK

    m@t

    The website is installed on WS 2003 and IIS 6.0 and there isn't any error logued in C:\WINDOWS\system32\LogFiles\HTTPERR\httperr.log.
     

    If you get a Bad Request response you should see the reason code in the httperr log file.

    m@t

    I restarted the IIS service administration and the machine but the issue has not been fixed.
     

    When you make changes to the http.sys listener service you need to re-start that service for the changes to take effect, not the IIS Admin service.

    To do this type net stop http followed by net start http at a command prompt.

    If that doesn't work then you probably need to increase the values of MaxFieldLength and MaxRequestBytes.

    Http.sys registry settings for IIS

    Regards,

    Paul Lynch
    MCSE
  • Re: URL too long - bad request

    Aug 13, 2009 04:46 AM|m@t|LINK

    Thanks for your answer.

     

    Paul Lynch

    If you get a Bad Request response you should see the reason code in the httperr log file.

    The error does not appear in the httperr log file. However, if i decrease the value of the  "MaxFieldLength", the error "Bad request" becomes "Bad request (Invalid URL)" and the error is logued. I think there is another problem but I don't know where...

     Here are the keys set in the registry:

     [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters]
    "MaxFieldLength"=dword:0000fffe
    "MaxRequestBytes"=dword:01000000
    "UrlSegmentMaxLength"=dword:00000200
    "UrlSegmentMaxCount"=dword:00000000
    "AllowRestrictedChars"=dword:00000001
    "EnableNonUTF8"=dword:00000001
    "MaxBytesPerSend"=dword:000fffff
    "UriMaxUriBytes"=dword:01000000
    "DisableServerHeader"=dword:00000001

     

    Paul Lynch

    If that doesn't work then you probably need to increase the values of MaxFieldLength and MaxRequestBytes.

     I think that I already set the maximum values.

  • Re: URL too long - bad request

    Aug 13, 2009 06:56 AM|Paul Lynch|LINK

    m@t

    URL example :

    http://www.domain.com/uoQ76Kb2QL5hzaVOSAKWeX0W9LfDLqphmRXpsfHN8tgF5lCsfTxlOVWY8vFwzhsRzoNYKhUIOTc5TnUlT0vpdQflPyk2nh7vurXOj60cDnkG3nsrXMhFCsPjhcZAic2jKpF9F9TYRYQwJo81IMi6gY01RK3ZcNl8WGfqcvoZ702UIdetvR7kiaqo1czwSJCMjRFdG6EgMzgXrwE8DYMz4fWqoa1F1c1qwTCBk3yOcmGTbxsPSJK5QRyNea9IFLrBTjfE7ZlN2vZiI7adcDYJef.htm

    How are you creating this file ? I can't create a file with that name on Windows as it exceeds the maximum allowed filename length on an NTFS partition.

    Regards,

    Paul Lynch
    MCSE
  • Re: URL too long - bad request

    Aug 13, 2009 07:41 AM|Paul Lynch|LINK

    m@t

     I think that I already set the maximum values.
     

    No, the maximum value for MaxFieldLength is 65534 bytes and the maximum value for MaxRequestBytes is 16777216 (16MB) bytes

    Regards,

    Paul Lynch
    MCSE
  • Re: URL too long - bad request

    Aug 13, 2009 08:10 AM|m@t|LINK

    Thanks for your answers.

     

    Paul Lynch

    No, the maximum value for MaxFieldLength is 65534 bytes and the maximum value for MaxRequestBytes is 16777216 (16MB) bytes
     

     I have modifed the value, same error.

    Paul Lynch

    How are you creating this file ? I can't create a file with that name on Windows as it exceeds the maximum allowed filename length on an NTFS partition.
     

    The file doesn't exist, there is a httpHandler for the .htm extension.

     

     

     

  • Re: URL too long - bad request

    Aug 14, 2009 06:35 AM|WenJun Zhang - MSFT|LINK

    Since there is no error in httperr.log, it's very possible that some proxies or firewalls in the middle already deny the requests. I'd suggest you capture a netmon trace to verify this.

    Also definitely using such kind of long urls are not good enough approach. You should consider changing the design to use alternative things like form and POST method intead of putting so long parameters in GET requests.

    Thanks.

  • Re: URL too long - bad request

    Aug 14, 2009 10:28 AM|tomkmvp|LINK

    WenJun Zhang - MSFT

    using such kind of long urls are not good enough approach. You should consider changing the design

    +1 to that.

    See how many problems the design is causing?  It's simply not a reliable or recommended way to do things.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: URL too long - bad request

    Aug 14, 2009 11:09 AM|Vipinwipl|LINK

    There is limitation of URL leanth in IIS but you can use 'ISAPI_FILTER' to convert long URL into short URL.You can make rules for long URL in ISAPI_filter.

    VIpin 

     

  • Re: URL too long - bad request

    Jun 28, 2011 07:34 PM|dean_goddard|LINK

    We had this very same issue but with current technologies ie: IIS 7.5, Windows Server 2008 and ASP.NET 3.5. We needed to host our web app cookieless inside a clients I-Framed website and when some users, with longish email addresses went to log back in, to track their claim, they were hit with a BAD REQUEST.

    None of the IIS settings in the specific applications web.config worked.  And nothing was obvious.  Until this reasearch hunt 2 months later -

    Setting the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\UrlSegmentMaxLength to 512 characters worked a charm. 

    I need to post this as this STILL APPLIES TO TODAYS tech.

     

  • Re: URL too long - bad request

    Sep 07, 2011 01:35 PM|badripennati|LINK

     why cant we use POST instead of GET? I guess this should resolve the problem.