C
C#9mo ago
Peponis

Unhandled exception. System.IO.FileNotFoundException

Hi, so I am trying to publish my app to Azure and when i try to load the page it gives Application Error. When searching application logs in azure i found this : Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings..json' was not found and is not optional. The expected physical path was '/home/site/wwwroot/appsettings..json'. My program.cs (the part where I configure the appsettings) :
var builder = WebApplication.CreateBuilder(args);

var configuration = new ConfigurationBuilder()
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", false)
.AddJsonFile($"appsettings.{Environment.UserName}.json", true)
.Build();
var builder = WebApplication.CreateBuilder(args);

var configuration = new ConfigurationBuilder()
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", false)
.AddJsonFile($"appsettings.{Environment.UserName}.json", true)
.Build();
And I uploaded the stracture of my appsettings. Am very new as a developer, so if you need me to provide somethimg more tell me . Thanks in advance.
No description
No description
4 Replies
Pobiega
Pobiega9mo ago
Environment.UserName is not set on Azure, so it returns a blank string that means you are trying to load appsettings..json
Peponis
PeponisOP9mo ago
Thanks for your response, how can i configure it
Pobiega
Pobiega9mo ago
No clue, I don't do azure.
Peponis
PeponisOP9mo ago
I'll find out, thanks for the help
Want results from more Discord servers?
Add your server