This is a new one for Razor Pages. Basically, we can have custom actions being fired before or after a Razor Page's model method. As for the other filters, it is available in synchronous (IPageFilter
) and asynchronous flavors (IAsyncPageFilter
). Starting with the synchronous version, it declares three methods:
OnPageHandlerSelected
: Called after the framework selects a target handler method for the processing of the request, giving developers a chance to change thisOnPageHandlerExecuting
: Called before the handler is invokedOnPageHandlerExecuted
: Called after the handler is invoked
OnPageHandlerSelected
takes a parameter of type PageHandlerSelectedContext
, and this class offers the following properties:
ActionDescriptor
(CompiledPageActionDescriptor
): Describes the handler and model classesHandlerMethod
(HandlerMethodDescriptor
): The method that will be called, and can be changedHandlerInstance
(object
): The instance that will handle the request
The pre-event handler, OnPageHandlerExecuting...