在的WebAPI,我应该在哪里保存调用之间的数据,以我的ActionFilter? [英] In WebApi, where should I save data between calls to my ActionFilter?
本文介绍了在的WebAPI,我应该在哪里保存调用之间的数据,以我的ActionFilter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个<一个href="http://msdn.microsoft.com/en-us/library/system.web.http.filters.actionfilterattribute%28v=vs.108%29.aspx"相对=nofollow> 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
的要求。
这篇关于在的WebAPI,我应该在哪里保存调用之间的数据,以我的ActionFilter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文