Skip to content

asp.net razor page #2531

Closed as not planned
Closed as not planned

Description

If I have an asp.net core razor page, with no controller, how do I hook the dependency injection as suggested in

#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");
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions