Solved

Membership Provider session vs cache

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Duplicate a row 2 46
getting id from database 5 37
Registering DLL 5 43
Remove greater than sign 3 42
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.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now