ConfigurationBuilder does not contain a definition for SetBasePath | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

ConfigurationBuilder does not contain a definition for SetBasePath

Date- Mar 03,2021

14639

Appsetting jso Dot Net Core

Issue-

So , while working with .Net core you often need to read app json file from siteroot to access connection string and other keys available there. So in previous versions we used to use Configuration Builder for reading json file using SetBasePath Method.We used to write

new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appSettings.json").Build();

But the same code becomes non reachable when it comes to .Net core as  you receive error which is shown in below image saying 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' . So will see how to make this work in .Net core 3.1. 

So, This issue is basically because of a missing package in .Net core 3. So for this you have to add Microsoft.Extension.Configuration.json in your project. You can find this package on Nuget package as shown in image.


You can also install this package using Package Manager console using this command. For more reference you can have a look at https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json and then have a look at installation steps.

Install-Package Microsoft.Extensions.Configuration.Json -Version 5.0.0

So , after you successfully install this package you can check SetBasePath method will start working as expected. You can have a look at below image.


So ,you can follow the steps and this is how you can read app.json file in .Net core 3.1. 

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1190
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts