ASP.NET Core/MVC6中的WebTelemetryInitializerBase [英] WebTelemetryInitializerBase in ASP.NET Core / MVC6
问题描述
是否有MVC6兼容版本的WebTelemetryInitializerBase
可以与ASP.NET Core(在完整的.NET Framework上一起使用)?
Is there an MVC6 compatible version of WebTelemetryInitializerBase
that would work with ASP.NET Core (on the full .NET Framework)?
请参见我的问题在这里,我问如何在自己的计算机中获取HttpContext
临时初始化器.不幸的是,我没有指定我使用的是MVC 6,因此没有使用System.Web.HttpContext
.
See my question here where I asked how to get HttpContext
in my temeletry initializers. Unfortunately I didn't specify that I was using MVC 6 and thus no System.Web.HttpContext
.
推荐答案
是的,aspnetcore有此版本.查看 ASP.NET Core应用程序的Microsoft应用程序见解回购.
Yes, there is a version of this for aspnetcore. Check out the Microsoft Application Insights for ASP.NET Core applications repo.
有一个实现可在/src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/WebUserTelemetryInitializer.cs ,您可以将其用作指南.
There is an implementation of getting the WebUser found in /src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/WebUserTelemetryInitializer.cs which you can use as a guide.
The TelemetryInitializerBase
class is the one that consumes the IHttpContextAccessor
which is used to get the HttpContext.
从那里您可以获取 查看全文