© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
5 replies
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.
errorWebApp.PNG
appsettings.PNG
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Exception System.IO.FileNotFoundException
C#CC# / help
4y ago
❔ Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly
C#CC# / help
3y ago
✅ System.IO.FileNotFoundException
C#CC# / help
2y ago
Exception thrown: 'System.BadImageFormatException' in BruhCode2.dllAn unhandled exception of type '
C#CC# / help
3y ago