Tengiz
Tengiz

Reputation: 8399

How to force MVC action to do something specific

Simply talking, ActionFilter is good to check something before executing the action. What is there to check the action execution result? Is there anything that can be applied after action has executed?

For clarity, I need to check whether Session["UserID"] is set after action has completed its execution.

Any suggestions?

Upvotes: 0

Views: 123

Answers (1)

Keltex
Keltex

Reputation: 26426

Use OnActionExecuted in your ActionFilter to check after the action has executed. More information from MSDN. Example here:

protected override void OnActionExecuted(ActionExecutedContext ctx) {
  base.OnActionExecuted(ctx);
  ctx.HttpContext.Trace.Write("Log: OnActionExecuted",
      "After " +
      ctx.ActionDescriptor.ActionName);
}

Upvotes: 3

Related Questions