How can I get route values from inside my OnActionExecuting
filter method.
I had the following two suggestions but I am still confused:
ControllerContext
in the method and that gives you access to RouteValues
so filterContext.Controller.RouteValues
filterContext.Controller.RouteValues
I have for example the method:
public ActionResult Delete(string city, string street) {
//enter code here
}
If I want to get the value of city and street then how can I do this. Sorry if it seems like a basic question but I am not sure how to get access to the above.
Here it is,
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var parameters = filterContext.ActionParameters;
var email = parameters["email"];
var city = parameters["city"];
}
I think you're trying to preempt some controller action (like Delete
) with "enter code here":
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
string city = filterContext.ActionParameters["city"];
string street = filterContext.ActionParameters["street"];
// probably include this:
//base.OnActionExecuting(filterContext);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With