【发布时间】:2015-10-05 04:04:19
【问题描述】:
我希望如果用户无权访问特定页面,则将重定向到该页面“ErrorAccessPage.cshtml”。此页面没有任何控制器。它位于文件夹名称Shared中。
逻辑如下:
if (user has access){
return View();
}
else
{
return RedirectToAction("//how to input the page here?");
}
更新:
在我把代码改成这样之后:
if (moduleViewModel.CanRead == true){
return View();
}
else
{
return RedirectToAction("~/Shared/ErrorAccessPage.cshtml");
}
【问题讨论】:
-
return View("yourViewName"); -
return RedirectToAction("~/Shared/ErrorAccessPage");
标签: c# asp.net-mvc-5