title: How do I redirect user to another Controller Action from an ASP.MVC 3 action filter?
body: <p>In building a custom ASP.MVC 3 Action Filter, how should I redirect the user to another action if my test fails? I would like to pass along the original Action so that I can redirect back to the original page after the user enters the missing preference.</p>
  
  <p>In controller:</p>
  
  <pre><code>[FooRequired]
  public ActionResult Index()
  {
      // do something that requires foo
  }
  </code></pre>
  
  <p>in a custom filter class:</p>
  
  <pre><code>// 1. Do I need to inherit ActionFilterAttribute or implement IActionFilter?
  public class FooRequired : ActionFilterAttribute
  {
      public override void OnActionExecuting(ActionExecutingContext filterContext)
      {
          if (TestForFoo() == false)
          {
              // 2. How do I get the current called action?
  
              // 3. How do I redirect to a different action,
              // and pass along current action so that I can
              // redirect back here afterwards?
          }
  
          // 4. Do I need to call this? (I saw this part in an example)
          base.OnActionExecuting(filterContext);            
      }
  }
  </code></pre>
  
  <p><em>I'm looking for a simple ASP.MVC 3 filter example. So far my searches have lead to Ruby on Rails examples or ASP.MVC filter examples much more complicated than I need. I apologize if this has been asked before.</em></p>