发生了什么事filterContext.Cancel(ASP.NET MVC) [英] What happened to filterContext.Cancel (ASP.NET MVC)

查看:211
本文介绍了发生了什么事filterContext.Cancel(ASP.NET MVC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RC1之前我们做了这样的事情:

Before RC1 we did something like this:

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

这是现在没有了,我们如何与RC1达到同样的效果?

This is gone now, how do we achieve the same results with RC1?

谢谢,

凯尔

推荐答案

而不是一个取消您只需要设置属性的ActionResult 来得到不同的结果。所以对于取消属性,你只需要更换你的取消= TRUE

Instead of a Cancel property you just need to set the ActionResult to a different result. So for the Cancel property, you just have to replace your Cancel=true with

filterContext.Result = new HttpUnauthorizedResult();

参考

重大更改为RC1:

AuthorizationContext - 不再有取消属性

的UpdateModel - 不再接受的FormCollection

UrlHelper - 不再接受 ViewContext

<一个href=\"http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx\"相对=nofollow>斯科茨博客与白皮书的RC1的变化。

这篇关于发生了什么事filterContext.Cancel(ASP.NET MVC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆