Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'IConfiguration' does not contain a definition for 'Get'

People also ask

Does not contain a definition for GetValue?

IConfiguration does not contain a definition for GetValue. Typically appears when you're using IConfiguration outside of an Asp.Net Core app. In fact, GetValue is an extension method, so the solution is to simply add the following package: 1. Install-Package Microsoft.Extensions.Configuration.Binder.

Does not contain a definition for SetBasePath?

Fix: 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' To fix this error, you will have to install a new NuGet package Microsoft. Extensions. Configuration. Json .

What is IConfiguration?

The IConfiguration is an interface for . Net Core 2.0. The IConfiguration interface need to be injected as dependency in the Controller and then later used throughout the Controller. The IConfiguration interface is used to read Settings and Connection Strings from AppSettings. json file.


Install the NuGet package:

Microsoft.Extensions.Configuration.Binder

Duplicate: Bind an IConfigurationSection to a complex object without ASP.NET Core

Screenshot of NuGet packages


The Get method does not exist anymore. You have to use:

Configuration.GetSection("key").Value.ToString();