✅ CSS styles not loading on "Local" environment, only "Development"

I'm creating an application with razor pages. Everything went fine until I decided to switch from "Development" to "Local" for the environment in launchSettings.json. Now the website has no styles and my static files (css, js) are all empty when viewed in the browser. How do I fix this? Help really appreciated
11 Replies
Pobiega
Pobiega2w ago
That setting only really has three valid settings, Development (which ASP treats as development), Staging and anything else, which ASP treats as Production. Its likely that your templates have some env.IsDevelopment or similar in their branching
King TMK 🎗
King TMK 🎗OP2w ago
I see, but then why do for example my database connection strings work, which I put in appsettings.Local.json?
Sehra
Sehra2w ago
hosting adds by default appsettings.json and appsettings.{Environment}.json if you want to use local settings for connection string, it's better to put that in user secrets, which is added by default in development
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2w ago
as Sehra said, it still retains the value you gave for stuff like string interpolation, but if you look at the startup logs, I'm fairly sure you'll see...
[11:05:38 INF] Application started. Press Ctrl+C to shut down.
[11:05:38 INF] Hosting environment: Production
[11:05:38 INF] Application started. Press Ctrl+C to shut down.
[11:05:38 INF] Hosting environment: Production
hosting environment really only has 3 values, Dev, Staging and Prod
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2w ago
idk what Local is supposed to be other than Development
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2w ago
yup
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
King TMK 🎗
King TMK 🎗OP2w ago
Thank you for your help everyone

Did you find this page helpful?