How can I get route values from inside my ActionExecuting filter?

前端 未结 2 1036
独厮守ぢ
独厮守ぢ 2021-01-12 22:43

How can I get route values from inside my OnActionExecuting filter method.

I had the following two suggestions but I am still confused:

  1. A
相关标签:
2条回答
  • 2021-01-12 23:23

    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);
    }
    
    0 讨论(0)
  • 2021-01-12 23:30

    Here it is,

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var parameters = filterContext.ActionParameters;
            var email = parameters["email"];
            var city = parameters["city"];
        }
    
    0 讨论(0)
提交回复
热议问题