I'm trying to work out how to re-use some code in my MVC controller actions. I want to redirect to another page if a status of something is set. I've written a method to do this but it seems as if I'd have to paste this across every controller action e.g.
[HttpGet]
public virtual ActionResult DoThis(Guid id)
ActionResult result;
if (checkRedirect(out result))
{
return result;
}
//otherwise continue
I thought I might be able to do this using an Action Filter but then I have to set up property injection in the filter in order to check my status which I want to avoid. There must be a common way of doing this that I'm missing...?