It appeared that this path was never getting to the code, but being bounced back by IIS. The URL http://localhost:54612/mydir/40399 worked just fine.
After further research we found that it was number at the end with 404 in it that was breaking us. http://localhost:54612/mydir/30404 also broke.
The code we were using was
Once we changed it to
RouteTable.Routes.Add(new Route(@"mydir/invoice", new PathRouteHandler("~/myotherdir/file.aspx")));
We had to change the catching code to check the query string instead of the route path, but it worked.
We have yet to discover why it was behaving badly with invoice numbers containing 404. I would love to read your thoughts if you have run across such a thing.