asp.net mvc 4 - System.Web.Security.Roles.GetRolesForUser(currentUser.Identity.Name) just one time works true -


in internet mvc 4 project, when run project in debug mode,and login application,the role user wich assigned before recognized. function use getting user roles :

system.web.security.roles.getrolesforuser(currentuser.identity.name) 

but when stop debugging, , again run application in debug mode, user authenticated getrolesforuser return string[0]. why occures , doesn't return role?

i had same issue , fixed change way of finding roles:

var manager = new usermanager<applicationuser>(new userstore<applicationuser>(new plutusdbcontext()));  var user = manager.findbyname(currentuser.identity.name); var userroles = manager.getroles(user.id); 

ps: i'm using microsoft.aspnet.identity 2.0.1


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -