我有一个与动作重定向有关的小问题。我想阻止用户使用我的BaseController类中的OnActionExecuting类来访问站点中特定区域的信息,这是我所有控制器的基类。方法体:MVC 3重定向不起作用
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (Request.IsAuthenticated && (User as Eagle.Security.EaglePrincipal != null) && Session != null && Session["LastKnownGoodArea"] != null && filterContext.ActionDescriptor.ActionName != "InvalidPermission")
{
var currentArea = Principal.CurrentCenter.CODEFORM_CSE;
if (currentArea != Session["LastKnownGoodArea"].ToString())
RedirectToActionPermanent("InvalidPermission", "Account", new { target = 0, redirectURL = null as string });
else
base.OnActionExecuting(filterContext);
}
}
但是,这不会重定向到指定的操作。我究竟做错了什么?如果有其他方法,你们会建议吗?
感谢, 的Silviu
请看这里:http://stackoverflow.com/questions/4909670/asp-net-mvc-3-redirect-to-another-action – Pandian 2013-02-11 13:27:02
嗯,这不是一个真正的选择,因为在某些情况下,我只是想调用基类(Controller)OnActionExecuting,它具有void作为返回类型,而这正是它应该如何工作的。 – 2013-02-11 13:31:36