ApplicationInsights-dotnet
ApplicationInsights-dotnet copied to clipboard
asp.net razor page
If I have an asp.net core razor page, with no controller, how do I hook the dependency injection as suggested in
https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 and https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#how-can-i-track-telemetry-thats-not-automatically-collected
The code as follows runs but the events are never written when I use the dependency injections methods for .net core. Other regular app insights events process fine.
namespace simplewebapp.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private TelemetryClient telemetry;
public IndexModel(ILogger<IndexModel> logger, TelemetryClient telemetry)
{
_logger = logger;
this.telemetry = telemetry;
telemetry.TrackEvent("IndexPage_IndexModel");
}