Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Membership Provider session vs cache

Posted on 2010-11-20
4
Medium Priority
?
875 Views
Last Modified: 2012-08-14
Hello.

I've created a custom membership and role provider for our site. Essentially it loads a dataset of commonly used user data into that user's session after authentication. This way we limit some of the DB calls throughout the site. All updates work OK since I first update the session dataset then then database when updates occur.

One issue I've now run into is that the user's can change their names through an admin page that is queued up. The admins then accept/deny the change. If they accept the change, the user info is updated in the database... but not the user's session object (obviously). This creates a problem with the user data not being updated when they are logged in.

Anyone have any good ideas on how to handle the admin update so as not to compromise the data integrity when the user is logged on?

Is there any reason I can't hold the user's session dataset in the applications cache instead? That way the admins and the users are updating the same dataset when the user is logged in.
0
Comment
Question by:dacIT
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Jesse Houwing
ID: 34182778
Place the details in the Application object, that is kind of the Session object, but then for the whole application. You will need to implement a readerwriterlock on the variable, otherwise different threads can override each others changes.

Here is a (rather old) article on how to use the Application scope.
http://www.eggheadcafe.com/articles/20030211.asp

One issue with this setup is that the Application scope is linked to the AppPool the site runs under, so if you have multiple hosts in your setup, each will have its own instance of the data. You should consider using AppFabric Caching as an alternative if this scenario applies to you.
0
 
LVL 7

Author Comment

by:dacIT
ID: 34245614
Wow thanks. Hadn't even heard of the application variable.

It still seems to me that the global cache might be better in that I can purge that on a time schedule pretty easily after so many minutes of disuse.

Is the HttpRuntime.Cache object the same across server farms?
0
 
LVL 17

Accepted Solution

by:
Jesse Houwing earned 2000 total points
ID: 34246179
Not, the cache is not synced across farms, neither is the application variable.

If you use AppFabric Caching, you can have a centralized cache cluster.
0
 
LVL 7

Author Closing Comment

by:dacIT
ID: 34249875
Thanks for your help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

877 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