Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

URL too long results in Bad Request (Invalid URL)

677 views
Skip to first unread message

JPElectron

unread,
Feb 24, 2008, 12:05:45 AM2/24/08
to
I have a site based entirely in .asp - occasionally a link to a page
(URL + query string) will be generated that seems to be too long for
either the browser to display or the web server to serve...

For example, if the address bar has a URL with 375 characters, all you
get is: Bad Request (Invalid URL)

If it has 371 characters, I still get: Bad Request (Invalid URL)

If I cut off a few, so it's 370 characters or less, the page will
display fine. Note that I'm not changing anything else in the line,
I'm just cutting off a few characters (numbers in this case) from the
end.

The real question here, is when I set a custom 400 error, which I
assume is what's producing the: Bad Request (Invalid URL) error to
display - I can't get my custom error page to display, I still get
just: Bad Request (Invalid URL)

Any idea why my custom error isn't working?

Ken Schaefer

unread,
Feb 24, 2008, 5:22:26 AM2/24/08
to
What version of IIS are you using? in IIS 6.0, 400 errors are usually
generated by http.sys, not by IIS

Check httperr.log file to see if http.sys is generating the error. If so,
then I don't think there's anything you can do to customise that error
message.

Cheers
Ken

"JPElectron" <jp.m...@gmail.com> wrote in message
news:46099665-1e26-4d45...@q33g2000hsh.googlegroups.com...

JPElectron

unread,
Feb 24, 2008, 7:31:34 PM2/24/08
to
yes, I'm using IIS 6 (Windows 2003) and your right, these errors show
up in WINDOWS\system32\LogFiles\HTTPERR\httperr1.log

So what's the point/difference in defining a custom 400 error in IIS?

Is there any way to show a different page/message when this happens?

Ken Schaefer

unread,
Feb 25, 2008, 4:11:44 AM2/25/08
to
"JPElectron" <jp.m...@gmail.com> wrote in message
news:42e681a3-7511-4de5...@c33g2000hsd.googlegroups.com...

> yes, I'm using IIS 6 (Windows 2003) and your right, these errors show
> up in WINDOWS\system32\LogFiles\HTTPERR\httperr1.log
>
> So what's the point/difference in defining a custom 400 error in IIS?

I suppose for 400 errors that are generated elsewhere. You can certainly
write your own app that generates "Bad Request" status for whatever reason
you feel like (even if the request technically doesn't contravene the HTTP
specification)

> Is there any way to show a different page/message when this happens?

Not that I'm aware of - well, not within IIS (since http.sys is lower down
in the stack). I don't know much about interfacing with the http.sys API,
but that would probably be the place you'd need to do this work.

Oddly enough, I didn't think that the HTTP spec defined a length for URIs,
and 400 characters seems like a low limit (unless there's also a
corresponding limit in file paths lengths in Windows - maybe in FAT32 -
since that would be the lowest common denominator file system).

Cheers
Ken

Bernard Cheah [MVP]

unread,
Feb 25, 2008, 10:07:30 PM2/25/08
to
Anything that is kernel mode response, you can customize the error page,
just like 503.

Also bad request 400 for invalid url should not be related to url too long,
if you got then it should be url_length in the reason phrase.

what's so special about ur request url ?

--
Regards,
Bernard Cheah
http://www.iis.net/
http://msmvps.com/blogs/bernard/


"Ken Schaefer" <kenR...@THISadOpenStatic.com> wrote in message
news:eEM2254d...@TK2MSFTNGP04.phx.gbl...

JPElectron

unread,
Feb 26, 2008, 1:33:27 AM2/26/08
to

Bernard Cheah [MVP]

unread,
Feb 26, 2008, 2:06:41 AM2/26/08
to
Correction on previous post - I mean "you can't customize'... as it is
kernel mode.
mm.... your sample url trigger nothing on my mind. just 5 char diff :)

can you post the complete line of the httperr.log file?
it didn't reach IIS log right?

"JPElectron" <jp.m...@gmail.com> wrote in message

news:3533059d-7fdf-4789...@64g2000hsw.googlegroups.com...

Daniel Crichton

unread,
Feb 26, 2008, 8:13:47 AM2/26/08
to
JPElectron wrote on Mon, 25 Feb 2008 22:33:27 -0800 (PST):

> Based on some DNS trickery I am able to resolve the domains of some
> sites (lets just say unwanted sites) to my own IIS server instead (this
> based on corporate policy)

> Here are the sample URLs, although I've changed the domain-names to
> protect the guilty...

Have you got URLScan installed and enabled? It has options for setting
allowable lengths on URLs. Also there are registry settings for HTTP.sys,
but I've checked my own server and they're not present by default:

The HTTP.SYS component used by IIS 6.0 allows size limits to be set on
various parts of the request. The values can be changed by modifying
AllowRestrictedChars, MaxFieldLength, UrlSegmentMaxLength, and
UrlSegmentMaxCount in the registry under the following registry keys:
菱KEY_LOCAL_MACHINE\System\CurrentControlSet\
Services\HTTP\Parameters\AllowRestrictedChars
菱KEY_LOCAL_MACHINE\System\CurrentControlSet\
Services\HTTP\Parameters\MaxFieldLength
菱KEY_LOCAL_MACHINE\System\CurrentControlSet\
Services\HTTP\Parameters\UrlSegmentMaxLength
菱KEY_LOCAL_MACHINE\System\CurrentControlSet\
Services\HTTP\Parameters\UrlSegmentMaxCount


(above from http://www.microsoft.com/technet/security/tools/urlscan.mspx)

--
Dan


0 new messages