首页 > 解决方案 > 身份中的 RedirectToLocal 角色明智重定向

问题描述

使用不同角色登录时遇到问题,有什么有效的方法可以使用角色重定向角色页面?

 private ActionResult RedirectToLocal(string returnUrl)

     {

        if (Url.IsLocalUrl(returnUrl))
        {
            return Redirect(returnUrl);
        }
        if (string.IsNullOrEmpty(returnUrl))
        {
            if (User.IsInRole("Admin"))
            {
                return RedirectToAction("Index", "Role");
            }                
        }
        return RedirectToAction("Index", "Home");            
    }

标签: asp.net-mvcauthenticationauthorizationasp.net-identityroles

解决方案


推荐阅读