2

I want to send appId variable value to filter

// GET api/filter
[CustomFilter]
public IEnumerable<string> Get()
{

   var  appId = 123;
    return new string[] { "value1", "value2" };
}

I can use either OnActionExecuting or OnActionExecuted method

public override void OnActionExecuting(HttpActionContext actionContext)
{
            base.OnActionExecuting(actionContext);

           //here i want to access appId value

}

I know how to access parameter values using querystring

3
  • ok got it,,actually issue is i have to send dynamic value of appid to filter,,how will i achieve that Commented Aug 1, 2014 at 14:11
  • Where is the value coming from? Commented Aug 1, 2014 at 15:24
  • I have same issue . please help me Commented Dec 11, 2015 at 12:12

1 Answer 1

5

From the controller action method, set the value in the Properties dictionary of the request object, like this: Request.Properties["AppId"] = 123;.

In the OnActionExecuted method of the filter, retrieve it like this: actionContext.Request.Properties["AppId"].

BTW, you must use the OnActionExecuted method of the filter, if the value is set in the action method. The OnActionExecuting method runs before the action method is executed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.