Role Test is not recognized in the account controller, the Role "Test" exists. In the view the Role is recognized
Why are Roles not available in the account controller ? (i am using the asp.net / authentication template from visual studio
This works
@if (User.IsInRole("Test")) {<li><a href="~/Partner">Test</a></li>}
Here it does not work
// POST: /Account/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } // This doen't count login failures towards lockout only two factor authentication // To enable password failures to trigger lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); switch (result) { case SignInStatus.Success: var user = await UserManager.FindAsync(model.Email, model.Password); if (User.IsInRole("Test")) { return RedirectToAction("Index", "Test"); } else { return RedirectToLocal(returnUrl); } case SignInStatus.LockedOut: return View("Lockout"); case SignInStatus.RequiresVerification: return RedirectToAction("SendCode", new { ReturnUrl = returnUrl }); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return View(model); } }