Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  • Register
  • Login
  1. Home
  2. Blogpost

ConfigurationBuilder does not contain a definition for SetBasePath

Date- Mar 03,2021

19173

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. 

S
Shubham Batra
Programming author at Code2Night โ€” sharing tutorials on ASP.NET, C#, and more.
View all posts โ†’

Related Articles

Understanding Memory Management and Garbage Collection in .NET
Mar 16, 2026
Understanding Records and Pattern Matching in C# 9 and Above
Mar 16, 2026
Understanding Extension Methods in C#: Enhancing Your Code with Ease
Mar 16, 2026
Mastering Design Patterns in C#: Singleton, Factory, and Observer
Mar 16, 2026

Comments

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
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 | 1760
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
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ยท  Terms
Translate Page