0

I know that you can use OnActionExecuting or an Action filter to inject parameters to an action method, but is it possible to change the action name itself? I was tempted to try this:

    Public Overrides Sub OnActionExecuting(filterContext As ActionExecutingContext)
        filterContext.ActionDescriptor.ActionName = "SomethingElse"
    End Sub

But this won't compile, because ActionName is ReadOnly. Is there a way to do what I need?

Joshua Frank
  • 13,120
  • 11
  • 46
  • 95

1 Answers1

1

You can change what action gets invoked by doing a redirect from within your OnActionExecuting by doing something like this:

filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary() {{"action", "Index"}, {"controller", "Home"}})

Also take a look at this SO question.

Community
  • 1
  • 1
Becuzz
  • 6,846
  • 26
  • 39