【问题标题】:What happened to filterContext.Cancel (ASP.NET MVC)filterContext.Cancel 发生了什么(ASP.NET MVC)
【发布时间】:2009-02-03 00:50:22
【问题描述】:
在 RC1 之前,我们做了这样的事情:
public void OnAuthorization(AuthorizationContext filterContext)
{
if (whatever)
{
filterContext.Cancel();
}
}
现在已经没有了,我们如何使用 RC1 实现相同的结果?
谢谢,
凯尔
【问题讨论】:
标签:
c#
asp.net-mvc
authorization
【解决方案1】:
您只需将ActionResult 设置为不同的结果,而不是Cancel 属性。因此,对于 Cancel 属性,您只需将 Cancel=true 替换为
filterContext.Result = new HttpUnauthorizedResult();
REFERENCE
RC1 的重大更改:
AuthorizationContext - 不再有 Cancel 属性
UpdateModel - 不再接受 FormCollection
UrlHelper - 不再接受ViewContext
Scotts Blog 与 RC1 的 White Papers 更改。