Find out the name of the controller and action before the request is serviced

xmaker

New Member
I want to intercept every request coming into my MVC app after the ControllerName and Action have been resolved, but before the request is serviced, i.e. before it reaches the appropriate action.I have thought of two ways of doing this:1) I could write an \[code\]HttpModule\[/code\] to intercept every incoming \[code\]HttpRequest\[/code\], read the \[code\]HttpContext.Request.AbsoluteUrl\[/code\] (or some such) property, then assume that the route I have configured will never be changed (and that is the assumption I want to avoid or I would have gone this way), and infer the names of the controller and action that are being invoked.However, I am looking for a more reliable way. Hence (2) below.2) I assume that MVC already does this for me at one time or another before instantiating the right controller. I want to know where it does that so I may be able to re-use its work. At which point may I get this information, intercept the request and do something about it before it reaches the action?
 
Back
Top