views:

18

answers:

1

I am building a small CMS system with ASP.NET MVC and I have a custom role provider using a userRepository instantiated by a factory implemented using Castle Windsor.

Someone with admin privileges can change the roles of a user, saved in a database, using the back-end administration.

But whenever I log onto the user for whom I just changed the roles (I use test users for the moment), the roles are not updated. I tried logging out and in again, with no result - the roles of my used remain the same. I also tried clearing the cache and cookies of the browser, with again no result.

The data is correctly updated in the database.

I have tried outputting the roles for a logged in user, so I could see if the data was updated in the my custom roleprovider, but the data in the roleprovider remains the same it seems. So apparently the roleprovider is not getting the data from the database on each request.

The funny thing is that, if I change a role and republish my website, the change bahaves as is should. Its just not an option to republish my website each time, an admin change the role of a user . thats not very dynamic.

Any ideas on why this occurs and how I can fix it?

A: 

I'm guessing your role provider is a singleton, which is the default lifestyle in Windsor, hence depending on how you implemented it, it likely holds the data it pulled on the 1st request. Make it PerWebRequest or transient.

See the documentation for more details on lifestyles.

Krzysztof Koźmic