views:

5

answers:

0

Hi,

In the master page for my site, i have added several LoginView controls that use roles to determine if menu items should be displayed to the logged in user.

In my Global.asax Application_Start() event i am adding roles for a set of users as defined in my Web.Config file (as additions to those already in Active Directory) - Like so:

HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(userId, UserRoles.ToArray());

UserRoles is a List populated from the application settings.

When i check in the immediate window after this has taken place, the roles are correctly added to the user. By the time the page_load event is fired in the master page, the roles are no longer set for the user. As a result, none of the Menu items display for any of the users i've specified in my app settings.

This problem only happens on our staging server (win server 2008), when i run the site on my development machine (using the visual studio development server) it works perfectly. I've re-deployed the site to ensure the code matches and i've compared the web.config files (they are identical except for a couple of unrelated dev verses staging settings).

So, i guess this must be something to do with the configuration of the staging server (IIS?)?

I was able to find a similar sounding problem on stackoverflow (http://stackoverflow.com/questions/56271/context-user-losing-roles-after-being-assigned-in-global-asax-application-authent) but the solution to that problem is not the cause of mine (i.e. my web.config doesn't contain <roleManager enabled="true"/>)

Can anyone suggest what might be causing this and how to fix it?

Thanks

related questions