Question

I'm trying to crate a custom action filter attribute. And some where, I need facilities, such us TempData[key] and TryUpdateModel... My custom attribute class deriving from the ActionFilterAttribute, I can access both below methods.

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
}

Unfortunately, from both filtercontext local variables, I don't know how to access the TempData. I've tried to follow several leads, but without success. After all, maybe there's TempData in the filterContext variables. In that case, how do I access the TemData available?

Thanks for helping

Was it helpful?

Solution

var foo = filterContext.Controller.TempData["foo"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top