Problems with Application Cache as a result of interrupted browser requests to server

Posted on 2008-02-02
Medium Priority
Last Modified: 2013-11-26
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.
Question by:drpettitt

Accepted Solution

sasapopovic earned 2000 total points
ID: 20813037
Hi drpettitt,

It looks to me like an concurent resource access issue. I assume you use the same reference to DataSet (or some other classes) instance in those two attempts and it gets updated when it shouldn't.

I suggest you lock the access to that DataSet or access to cache. You can check this article for an example of how to perform locks: http://www.codeguru.com/csharp/.net/net_asp/article.php/c5363/

I hope this will help you.


Author Closing Comment

ID: 31427571

Thanks for the help. Seems like I should have known this. Something about not seeing the forest for the trees comes to mind.

Thanks again,

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question