|
1
|
| OriginalUtter · 技术社区 · 7 年前 |
|
|
1
7
实际上,有一个例子。NET框架: https://blogs.msdn.microsoft.com/stuartleeks/2016/11/03/including-headers-for-request-events-with-application-insights/ 在里面NET核心,您只需使用IHttpContextAccessor而不是HttpContext来访问HttpContext。当前:
同时检查: https://github.com/Microsoft/ApplicationInsights-aspnetcore/wiki/Custom-Configuration |
|
|
2
1
您的第二种方法应该可以工作,并且您可以使用现有的扩展方法来获取当前的请求遥测(如果有)。
方法为方法:
这将返回给定HttpContext的当前请求遥测,因此您应该能够执行以下操作:
从你的Nancy模块内部? |
|
|
3
1
我找到了一个解决方案,可能不是最漂亮的,但至少它似乎有效。
我创建了一个静态可访问的
我设置的值为
然后,我在
|