title: Using MVC 4 & WebAPI, how do I redirect to an alternate service endpoint from within a custom filter?
body: <p>Thanks for looking.</p>
  
  <p>This is a trivial task when using a normal (not WebAPI) action filter as I can just alter the filterContext.Result property like so:</p>
  
  <pre><code> filterContext.Result = new RedirectToRouteResult(
                  new RouteValueDictionary { { "controller", "Home" }, {"action", "Index" } });
  </code></pre>
  
  <p>Unfortunately, I have to use <code>HttpActionContext</code> for WebAPI, so I can not access <code>filterContext.Result</code>.  </p>
  
  <p>So what should I do in place of that?  I have the filter set up and it does execute at the appropriate time, I just don't know how to make it prevent execution of the requested service endpoint and instead point to a different one.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>[VerifyToken]
  public class ProductController : ApiController
  {
      #region Public
          public List&lt;DAL.Product.CategoryModel&gt; ProductCategories(GenericTokenModel req)
          {
              return HelperMethods.Cacheable(BLL.Product.GetProductCategories, "AllCategories");
          }
  
          public string Error() //This is the endpoint I would like to reach from the filter!
          {
              return "Not Authorized";
          }
      #endregion Public
  
      #region Models
          public class GenericTokenModel
          {
              public string Token { get; set; }
          }
      #endregion Models
  }
  </code></pre>
  
  <p>Here is my filter:</p>
  
  <pre><code>using System.Web.Http.Controllers;
  using ActionFilterAttribute = System.Web.Http.Filters.ActionFilterAttribute;
  
  namespace Web.Filters
  {
      public class VerifyTokenAttribute : ActionFilterAttribute
      {
          public override void OnActionExecuting(HttpActionContext filterContext)
          {
              dynamic test = filterContext.ActionArguments["req"];
              if (test.Token != "foo")
              {
                  //How do I redirect from here??
  
              }
  
              base.OnActionExecuting(filterContext);
          }
      }
  }
  </code></pre>
  
  <p>Any help is appreciated.</p>