11

I've noticed weird behavior in IIS error pages. I've got this setup:

<httpErrors errorMode="Custom" existingResponse="Replace">
 <remove statusCode="500" />
  <error statusCode="500" responseMode="ExecuteURL" path="/error-page" />
</httpErrors>

Sometimes when an ASP.NET error occurs due to the query string being too long, then immediately the second error occurs while trying to execute the error page URL. I've tracked the problem to the fact that IIS appends the original url to the error page url like:

Original: http://example.com/someurl?id=some_very_long_query_string_causing_security_exception
Error: /error-page?500;http://example.com/someurl?id=some_very_long_query_string_causing_security_exception

This is a huge problem. If the original url fails for having a query string too long then the error page with the the appended stuff fails as well because it has a query string that is even longer!

I believe this is the dumbest bug in IIS. Does anyone know if there was some patch of service pack for that? Worst case scenario if nothing is fixed by now, is there a way to disable this behavior or any tricks to stop IIS appending unsolicited stuff to the error page? Because it breaks the whole custom error page mechanism.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
bunny
  • 111
  • 5

2 Answers2

1

Adding a trailing slash to the path (e.g. path="/error-page/") will stop the error code and URL being appended, note that it will keep the original failing URL, e.g.

mitchjhill
  • 11
  • 1
0

I similar issue a long time ago, the system in question uses static error pages because of it.

You can set that in the defaultResponseMode to file which will serves back a single static page.

httpErrors Element IIS Settings Schema

There is also a similar issue here

RickWeb
  • 285
  • 2
  • 13