When a view has been rendered in memory and before it is sent as a response to the client, I would like to intercept the call, check which view is being rendered, what was the action and controller, and do some house-keeping.
Therefore, I am implementing a ResultFilter and overriding the OnResultExecuted method.
Within this method, how do I get the route data to figure out which view, action, controller were called?
Update
My profuse apologies. I just looked up ResultExecutedContext in reflector and it showed me only an Exception, Cancelled and ActionResult property. It didn’t show me any RouteData. When I fired up the IDE, it did show me the route data. I feel like a dick for asking this question.
You could get it from the
filterContext‘sRouteDataproperty:As far as which view was rendered is concerned you could retrieve this information from the
Resultproperty:If on the other hand the controller action returned a JsonResult you could also extract retrieve it:
and so on…