I would like to run the following code in Index controller
public ActionResult Index()
{
if(User!=null)
{
if(0==(Roles.GetRolesForUser(username).ToList().Contains("administrator")))
{
//do something
}
}
return View();
}
I got an exception at GetRolesForUser when the Index page loads especially when the User is not null (the user is online/logged in)
The exception asks me to call WebSecurity's InitializeRoles in _appStart.cshtml file