Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to filterContext.Cancel (ASP.NET MVC)

Before RC1 we did something like this:

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

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

Thanks,

Kyle

like image 710
Kyle West Avatar asked Feb 03 '09 00:02

Kyle West


1 Answers

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();

REFERENCE

Breaking Changes for RC1:

AuthorizationContext - no longer has a Cancel property

UpdateModel - no longer accepts a FormCollection

UrlHelper - no longer accepts a ViewContext

Scotts Blog with the White Papers of RC1 changes.

like image 144
cgreeno Avatar answered Nov 02 '22 06:11

cgreeno