views:

46

answers:

1

I have two custom ActionFilters on an action.

In first of the actionfilters, I have an redirect performed if a condition is not met (classic authorization). And in another I have an redirect performed if another condition is not met (say role checking).

But I do not want to continue to the second actionFilter if the first one is not met. How to do this?

A: 

Setting the filterContext.Result property to any non-null value will stop execution of later filters. So if your first filter sets filterContext.Result = new RedirectResult(...), the second filter and action method will never be run. This is how the built-in [Authorization] filter works.

Levi