When I try to get roles from RoleManager
, I get list of very strange list of objects,
How I retrieve my roles:
public AppRoleManager RoleManager
{
get
{
return HttpContext.Current.GetOwinContext().GetUserManager<AppRoleManager>();
}
}
public IEnumerable<AppRole> GetRoles()
{
return RoleManager.Roles.ToList();
}
I didn't have this problem before, but I guess it might have something to do that I moved my whole web application with database to Azure? Could anyone point finger how to fix this?
So my problem is that when I load my page with that list passed as a model, it will throw exception error without any exception details. Just server error throws up.
Note: getting same way my user's UserManager
works like a charm.
I found the reason why this didn't work. I had a different version of System.Web.Mvc in my other project which handles identity than my web project. Upgrading to same version I didnt get anymore errors for retrieving roles from RoleManager. Strange that this didnt happen when I was gettin Roles from UserManager..