To create a filter, create a class that implements the
interface, then associate the filter with your controller.
You can always create an abstract controller class and associate a filter with it and make your controllers extend it.
public class AuthenticationFilter : IFilter
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller)
return value indicates to the framework if the process should be ended. If you return
no further process will happen for the current request. It is important that you take some action before, like in the example above, issuing a redirect.
parameter informs the filter about the context of the invocation. It is also used on the
to define when you want to have the filter executed. The possible values are listed in the table below:
|BeforeAction||The filter is invoked before the action.|
|AfterAction||The filter is invoked after the action.|
|AfterRendering||The filter is invoked after the rendering.|
|Always||The filter is invoked around all steps.|
To associate the filter with the controller, use the
public class AdminController : Controller
public void Index()