Solved

Membership Provider session vs cache

Posted on 2010-11-20
4
861 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 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

820 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