我想覆盖控制器OnActionExecuting方法,我会检查操作和控制器用户是否正确。
public class BrowseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
//TODO: ask service user has right this action.
//string actName = filterContext.ActionDescriptor.ActionName;
//string cntName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName
//foo(actName, cntName, userInfo) if return false go NoAccess page!
//filterContext.Result = new RedirectResult("_NoAccessRight");
base.OnActionExecuting(filterContext);
}
}
我想在用户权限验证后
filterContext.Result = new RedirectResult("_NoAccessRight");
但我无法获得页面“_NoAccessRight”以及〜/ shared / _NoAccessRight“
你能说出来吗?感谢。答案 0 :(得分:4)
为了以后的帮助
public class BrowseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.Result = new RedirectToAction("NoAccessRight");
}
public ActionResult NoAccessRight()
{
return View("_NoAccessRight");
}
}