Reputation: 13848
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?
Upvotes: 0
Views: 581
Reputation: 6857
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.
Upvotes: 1