【发布时间】:2015-10-15 03:51:55
【问题描述】:
我想知道是否可以通过custom action filter attribute 获取请求的时间?我有以下内容:
public sealed class FooFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
if (actionExecutedContext.Response != null)
{
var start = actionExecutedContext.Request.Headers.Date; //this is null
var end = actionExecutedContext.Response.Headers.Date;
}
}
}
我想知道处理请求所花费的总时间,但是我似乎无法访问发起请求时的 DateTime 值。
谢谢。
【问题讨论】:
标签: c# asp.net-web-api actionfilterattribute