-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Framework.ConfigurationModel assembly name changed to Microsoft.Framework.Configuration #25
Comments
@davidfowl Due to this change how can I rewrite public IConfiguration Configuration { get; set; } public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) which you provided in #13 I tried
but it does not work |
The idea is you add sources to |
Thank you. I've tried but it tells me that there is no definition for AddJsonFile. Is this method maybe not implemented yet, since I've seen AddIniFile? |
nvm, I've included "Microsoft.Framework.Configuration.Json": "1.0.0-*" dependency in project.json and it works now, thank you very much. |
Yesterday I have migrated from beta4 to beta6, I used the above change but I could not get the values(key) in controller
It throws exception in Configuration.Get as 'Iconfigurationbuilder does not contain a definition for Get. |
You have to call
|
@kirthik , thank u. but it throws error in my startup class I already defined the path I could not get the value of connection string from the config.json |
Sorry should have been more explicit in my earlier comment. You should either provide full path of file to
|
thank u.. I have already using this in my startup class, please see my comment... I just want to get the connection string value in my Controller. I also included the IApplicationEnvironment appEnv in the below code without success. please help
But in beta4, I can easily grab the values stored in config.json using the following code:
|
Where are you instantiating |
I am instantiating appEnv in my Startup Class... as follows :
I think the problem is with appEnv.. and still getting the same error
|
Try this var path = app.ApplicationBasePath;
Configuration = new ConfigurationBuilder()
.AddJsonFile($"{path}/config.json")
.AddEnvironmentVariables()
.Build(); |
This is ok in startup class(with path).. But how to get the connection string value/key which is defined in config.json in the controller. The following method returns error unable to resolve path.
|
you can't create a ConfigurationBuilder each time the you need the connection string.
|
@ngonzalezromero u r right... I am getting the connection string in the ConfigureServices as per ur comment... Could u guide me how to get the same in my controller/class ...?.. |
Usually you want to use DI to inject whatever you need to your controller's ctor.
and then inject it
How you structure your configuration data or settings object is totally up to you. |
Thank u Michaco, but when using this i am getting error:
I will try to Add IOptions Settings to the constructor of my MVC controller and let u know |
@nrkarthick for general discussions and issues please log an item in https://github.com/aspnet/Home/issues. Please create a GitHub repo with a simplified app that demonstrates the issue. |
what if I need var serviceUrl = settings.Options.ServiceUrl; in a utility class instead of Controller how to get IOptions settings in the ctor ?????? public HomeController(IOptions settings) |
We changed the assembly name and namespace of
Microsoft.Framework.ConfigurationModel
toMicrosoft.Framework.Configuration
.Configuration
class name is changed toConfigurationSection
.The text was updated successfully, but these errors were encountered: