1

I have a controller. On the controller's post method, there is a variable (an object variable) I want to pass to my action filter: the method:

public void OnActionExecuted(ActionExecutedContext context)...

Any suggestions on how achieve this?

1
  • If i understand your question, you are trying to access action method's parameter in action filter. Can you try to access it from context's route values? Commented Nov 17, 2018 at 3:41

1 Answer 1

5

Use HttpContext.Items. It's a key / value collection that exists for the duration of a single request.

In your controller, add something:

HttpContext.Items["Something"] = "something I need later";

Then in the OnActionExecuted method pull it out:

var something = context.HttpContext.Items["Something"] as string;

Everything you pull out will be of type object so make sure you cast it to what it was.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.