Skip to content

Has path handling to a config file changed? #474

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

Closed
guardrex opened this issue Apr 22, 2015 · 4 comments
Closed

Has path handling to a config file changed? #474

guardrex opened this issue Apr 22, 2015 · 4 comments

Comments

@guardrex
Copy link
Contributor

This was working a while back for the path to a config file in Startup.cs:

config = new Configuration().AddJsonFile("config.json");

I think referencing the path that way stopped working at some point, so I hard-coded a path there. Now that I'm publishing to the server, going back-and-forth between two hard-coded paths isn't going to be cool.

What's the proper way to set that path so that it will work locally and on the server?

@MikeSchlichting
Copy link

This line of code will work when you are running locally or on the server:

Configuration = new Configuration().AddJsonFile("config.json").AddEnvironmentVariables();

When running locally config.json will be used, when running on the server AddEnvironmentVariables() will override any config.json values with matching entries from Azure. From where in Azure do these variables come from? You set them in your Web App settings in the azure portal under Settings\Application Settings\App settings and Connection strings.

untitled

@guardrex
Copy link
Contributor Author

This is running in IIS 8 on a WS2012 VM.

@guardrex
Copy link
Contributor Author

There is an Application Settings area in IIS, but I was wondering if the path itself could be set so that the config.json is found locally. Since it's in the same folder as Startup.cs, I would have thought that a relative path would work there ... and I think it used to work that way a week or so ago. Otherwise, I will use the App Settings in IIS as you recommend.

@guardrex
Copy link
Contributor Author

The config filepath was causing the app to fail on the server. If I can't reference a project-based config.json file with a relative path, i.e.,

config = new Configuration().AddJsonFile("config.json");

How should that be done?

ryanbrandenburg pushed a commit that referenced this issue Nov 19, 2018
ryanbrandenburg pushed a commit that referenced this issue Nov 22, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants