In my application I have a string parameter called "shop" that is required in all controllers, but it needs to be transformed using code like this:
shop = shop.Replace("-", " ").ToLower();
How can I do this globally for all controllers without repeating this line in over and over? Thanks, Leo
Write a custom action filter, override
OnActionExecuting()
and apply the filter to all your controllers. (Or simply overridingOnActionExecuting()
in your base controller, if you have a base controller at all.) The action method would look something like this: