Samantha J T Star
Samantha J T Star

Reputation: 32798

Can I check parameters of the action method from within my OnActionExecuting?

I have the following action:

public ActionResult Delete(string city, string street) {

Is it possible for me to get the values of the city and street parameters from inside of an OnActionExecuting filter?

public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

Upvotes: 1

Views: 700

Answers (1)

Adam Tuliper
Adam Tuliper

Reputation: 30152

Do you basically want access to your route values here (as opposed to parameter values in a method which you don't have direct access since that is already a 'bound' method - it essentially is the same thing though)

Access your ControllerContext in the method and that gives you access to RouteValues so filterContext.Controller.RouteValues

ActionExecutingContext Class

ControllerContext Class

EDIT For completeness (based on your other post) this data is available if you want just the action parameters string city = filterContext.ActionParameters["city"];

this depends though on what you want to access as ther may be other route parameters not bound to parameter values.

Upvotes: 1

Related Questions