Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Exotic MVC routing throws System.IndexOutOfRangeException at Microsoft.AspNetCore.Routing.RouteValueDictionary #8499
We have a .NET Core 2.1 application in production on Azure. It has been, infrequently, coming down with an unrecoverable 500 error which necessitates a site restart. We have noticed the following exception/stack trace appearing in our Azure application insights log hundreds of times at these times.
We cannot easily reproduce the issue unfortunately; it happens unpredictably but with increasingly likelihood as time goes by.
Potentially relevant code; our route configuration:
Isn’t MapSubdomainRoute straight from MVC? I don’t currently have access to the solution to double check.
But as for threading, there is actually processing occurring on other threads, powered by Hangfire. Most of it revolves around doing some activity tracking; almost every controller action queues a Hangfire job which record the interaction.
Is there a known issue with this combination of effects?
It might be part of some sample code or test somewhere, but it isn't a feature we provide.
The HttpContext, RouteValueDictionary and most other things that are part of the request are not thread-safe. They are intended to be used inside the context of the currently executing request, and not in other threads.
Sorry for the delay in reply, other projects took over...
The developer who integrated this subdomain routing has since left the organisation; but it looks like this is the library he used in this instance:
We're using the current version, 1.1.0.
As this library doesn't appear in the stack trace, it did not occur to me to examine it.
Are there any clues in the error as to where in this library a problem may have occurred (if the problem is not instead due to the HttpContext being accessed off-thread)?