I'm not using NET Core, I'm developing using NET Framework 4.7.2.
The project is using a function called Directory.GetCurrentDirectory() to find the root folder.
NET Framework, the function finds the location where the project was launched, not the root folder of the project.
Because of this, the path changes depending on the execution environment, and when you build with IIS Express in Visual Studio 2022, the root folder is applied as "C:\Program Files\IIS Express" rather than the project folder.
Because of this, putting ".env" in the project root folder doesn't work.
This issue was in the past "dotnet/aspnetcore#4206" and was fixed in Net Core but not in Net Framework.
According to what I checked on https://stackoverflow.com/a/53655514, in NET Framework, you should use System.AppContext.BaseDirectory instead of System.IO.Directory.GetCurrentDirectory() to work properly. At this time, I confirmed that it normally finds the project root folder.
I'm not using NET Core, I'm developing using NET Framework 4.7.2.
The project is using a function called Directory.GetCurrentDirectory() to find the root folder.
NET Framework, the function finds the location where the project was launched, not the root folder of the project.
Because of this, the path changes depending on the execution environment, and when you build with IIS Express in Visual Studio 2022, the root folder is applied as "C:\Program Files\IIS Express" rather than the project folder.
Because of this, putting ".env" in the project root folder doesn't work.
This issue was in the past "dotnet/aspnetcore#4206" and was fixed in Net Core but not in Net Framework.
According to what I checked on https://stackoverflow.com/a/53655514, in NET Framework, you should use System.AppContext.BaseDirectory instead of System.IO.Directory.GetCurrentDirectory() to work properly. At this time, I confirmed that it normally finds the project root folder.