Inject the configuration by adding the following two lines at the top of your page:
@using Microsoft.Extensions.Configuration @inject IConfiguration Configuration
Then access the value like:
@Configuration["ApplicationInsights:InstrumentationKey"]
Inject IOptionsMonitor<MyOptions>
with an @inject
directive:
@using Microsoft.Extensions.Options @inject IOptions<ApplicationInsightsOptions> ApplicationInsightsOptionsAccessor
Then access the value like:
var instrumentationKey = ApplicationInsightsOptionsAccessor.Value.InstrumentationKey;
Additional information at Options pattern in ASP.NET Core | Microsoft Docs