Is there an MVC6 compatible version of WebTelemetryInitializerBase
that would work with ASP.NET Core (on the full .NET Framework)?
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
.
Yes, there is a version of this for aspnetcore. Check out the Microsoft Application Insights for ASP.NET Core applications repo.
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.
From there you can get the Microsoft.AspNetCore.Http.HttpContext.User
which is they type of System.Security.Claims.ClaimsPrincipal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With