我有一個與動作重定向有關的小問題。我想阻止用戶使用我的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