How to read appsettings.json in my _layout.chtml

In .net core mvc you can inject the configuration by adding the following two lines at the top of your view:

@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration

You can then access the value like this:

@Configuration.GetSection("ApplicationInsights")["InstrumentationKey"]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)