代码之家  ›  专栏  ›  技术社区  ›  Kyle West

filterContext.Cancel(ASP.NET MVC)发生了什么

  •  10
  • Kyle West  · 技术社区  · 17 年前

    在RC1之前,我们做了如下工作:

    public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (whatever)
            {
                filterContext.Cancel();
            }
        }
    

    谢谢

    凯尔

    1 回复  |  直到 13 年前
        1
  •  17
  •   mipe34 shivbits    13 年前

    而不是 Cancel 属性,只需设置 ActionResult 取消 属性,您只需更换 Cancel=true

    filterContext.Result = new HttpUnauthorizedResult();
    

    REFERENCE

    正在中断RC1的更改:

    AuthorizationContext -不再有

    UpdateModel FormCollection

    UrlHelper -不再接受 ViewContext

    Scotts Blog White Papers