在的WebAPI,我应该在哪里保存调用之间的数据,以我的ActionFilter?我的、数据、WebAPI、ActionFilter

2023-09-03 17:45:47 作者:发呆草

我有一个 ActionFilterAttribute ,做一些东西,之前和目标的行动之后。我想保存执行呼叫的状态在已执行通话使用 - 但这里我要救这个数据?

I have an ActionFilterAttribute which does some stuff both before and after the target action. I would like to save the state of the Executing call for use in the Executed call - but where should I save this data?

我希望是这样的:

public override void OnActionExecuting(HttpActionContext actionContext)
{
    actionContext.SavedState = Precomputation();
}

public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
    var pre = actionExecutedContext.ActionContext.SavedState;
    Postcomputation(pre);
}

SavedState 实际上不存在的,当然。我应该用什么代替呢?

but SavedState doesn't actually exist, of course. What should I use instead?

推荐答案

将项目添加到 actionContext.Request.Properties 的要求。

 
精彩推荐
图片推荐