Is there a way for me to catch all incoming requests to my ASP.NET MVC 4 app and run some code before continuing the request onward to the specified controller/action?
I need to run some custom auth code with existing services, and to do this properly, I'll need to be able intercept all incoming requests from all clients to double check some things with the other service.
The most correct way would be to create a class that inherits ActionFilterAttribute and override OnActionExecuting
method. This can then be registered in the GlobalFilters
in Global.asax.cs
Of course, this will only intercept requests that actually have a route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With