Sorry, folks, I had to reopen this issue : I tried the URL http://www.dotnetnuke.com/tabid/795/%20/Default.aspx - notice the %20 in the URL. I got an error page :
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /tabid/795/ /Default.aspx
I verified that this is not IIS which is returning the above page and my custom error page directives in web.config (see below) were not firing :
<customErrors defaultRedirect="~/ErrorPage.aspx" mode="On">
<error statusCode="403" redirect="~/ErrorPage.aspx" />
<error statusCode="404" redirect="~/404.htm" />
</customErrors>
Hence I assume it is an error page returned by ASP.NET. How do I get such errors to be redirected to my custom error page?