asp.net-mvc - 身份中的 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");
}
解决方案
推荐阅读
- javascript - 用天数计算未来日期
- reactjs - “未捕获的 TypeError:超级表达式必须为 null 或函数” - 根据我的代码,为什么会出现此错误?
- android - Volley 请求在 android api 19 中不起作用
- c# - C#页面无法重新加载回上一页,datagridview数据丢失
- iis-express - 无法使用命令行 VSIISExeLauncher.exe 启动进程
- authentication - 解释当用户登录网站时会发生什么
- java - HeapSort 实现有 NullPointerException
- python - 我的简单 while 循环将我的计算机挂在较大的输入上
- c# - 外部登录和 c# web api
- r - 如何为重复的case_when创建函数