無論發生什麼ActionExecutingContext上的取消屬性?在使用ActionFilterAttribute時如何中止RenderAction,或者是否有另一種方法來爲這隻貓蒙皮?ActionFilterAttribute:'取消'屬性在哪裏?
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if(!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
return;
}
base.OnActionExecuting(filterContext);
}
上述代碼繼續儘管離開OnActionExecuting操作來執行它已經被應用到在操作?
---繼原帖: 感謝下面的答案,不過,我不認爲我所做的上下文很清楚,我想無效以下電話:
<% Html.RenderAction("Menu", "Shared", new { id = Model.OtherUserId }); %>
當用戶未通過身份驗證時,此操作不會返回任何內容,我可以很容易地在視圖上放置一個'if'塊,但是,我想將規則保留在控制器中。
查看我對渲染操作的更新。 – 2010-01-26 12:41:23