Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
.Net IConfiguration has wrong folder context

In my .Net Core project I am using the IConfiguration interface to handle some configuration.

Inside my classes it is used like this:

public MyClass(IConfiguration configuration)
{
    var someValue = configuration.GetSection("Key").Value;
}

And everything works fine when I start the project.

The problem is when I start the program from another location, e.g. a Shortcut.

Then the IConfiguration tries so find the "appsettings.json" in the folder, where the shortcut is located.

Is there some way to configure the IConfiguration in a central place and define a constant folder where the settings should be searched for.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can try using ConfigurationProvider/ConfigurationBuilder to either use environment variables for the settings or can specify the location of appsettings.json and use it.

https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.configuration.configurationbuilder

over 4 years ago · Santiago Trujillo Relatório

0

Maybe i should have digged deaper into my code, and I found an Extensions class that searches the app.settings quite dirty. Sorry to bother you, but thanks for your help!

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda