【发布时间】:2013-07-05 11:56:52
【问题描述】:
我在我的 asp.net Web API 项目中使用迷你分析器,并希望跟踪在自定义 DelegatingHandler 中运行的某些代码的性能。
DelegatingHandler 内的调用 MiniProfiler.Current.Step() 不会显示在结果中。同一项目中的其他调用显示正常。
进一步调查显示,MiniProfiler.Current 是从WebRequestProfilerProvider 中的HttpContext.Current 检索到的。而HttpContext.Current 在从DelegatingHandler 调用时为空。
有没有更好的方法来检索 MiniProfiler.Current 以便它在处理程序中工作?
【问题讨论】:
-
也许这回答了你的问题? [MvcMiniProfiler 是否需要 Web 应用程序才能工作,还是可以在纯库中使用,例如在单元测试中?][1] [1]:stackoverflow.com/questions/8526609/…
标签: asp.net-web-api mvc-mini-profiler