I’ve created a simple ASP.NET app, with the basic template, nothing changed. And I added a connected service for Azure Application Insights for my app. It’s all good and it shows in my Azure Portal account, the live metrics are showing some things:
The problem is, I cannot access my page views, not in portal and not in visual studio:
So what could be the problem, what I missed or what I forgot to add? Also. I don’t have an applicationinsights.config file.
2
Answers
Earlier after adding
Application Insights
fromConnected Services
,applicationinsights.config
used to get created automatically in the root directory of the Application.But now – a -days, we don’t see it.
applicationinsights.config
manually.We can Track
Page Views
in 2 ways.Way 1:
I have taken the refences from the MSDoc.
Add the below script in the
.cshtml
files, where you want to track the views.OutPut:
Way 2:
applicationinsights.config
manually.In
applicationinsights.config
,IncludeType
forPageView
.Application Insight ConnectionString
.My
Program.cs
file:My
appsettings.json
file:You can check the official doc, and I add below code and it works for me.
Follow this doc to troubleshoot,and add below code in page. You should use
connectionString
, instead ofinstrumentationKey
.Test Result
In azure portal metrics
Tips
Don’t forget to click here to change the data resource.
In VS2022