I have a legacy web application that I recently migrated from .NET 1.1 to .NET 2.0.
1. This application has a http handler defined and is configured as follows in the web.config:
<add verb="*" path="*.aspx" type="AssetMgmt.SecurityHttpHandlerFactory, AssetMgmt" />
2. The application cache is setup with common tables of data during the Application_Start event.
3. During the Application_BeginRequest event, the cache is checked for validity, and if it is not valid or null, the cache is reloaded.
4. During the Application_AuthenticateRequest event, several security related datasets (including user accessible web-pages) associated with the current user are added to the context.
5. The http handler uses the accessible web-page dataset mentioned in 4 above to determine if the user has access to a given web page. If the user does not have access, the user is redirected to an Unauthorized page.
We have an intermittant problem which normally happens during the first access of this web application in the morning, where since the cache has expired overnight, it has to be reloaded. As a result, the response from the server is really slow. As a result of the slow response, the user will re-request the web application before the original request has completed. The user does this by either reselecting the web-site from Internet Explorer Favorites or hitting return on the address bar multiple times. The result is that during 4 above, during the loading of the security datasets, an exception with a message of "Constraint matches constraint named Constraint2 already in collection." is thrown and handled and then during 5 above, the web-site is not included in the accessible web-site dataset so the user is redirected to the unauthorized page.
I am trying to understand why this happens and how to fix the problem.