How I Fixed Morning 404 Errors in My ASP.NET Core App Without Writing a Single Line of Code


Yo, if you’ve ever hosted an ASP.NET Core app on IIS and got slapped with random 404s first thing in the morning, I feel you. I just went through this nonsense and figured it out without touching a single line of code. Straight-up IIS config fix. Let me walk you through it.
The Headache
Every morning, I’d try hitting this URL: http://10.1.2.09:7004/Ecom/Accounts/Login
And boom: 404 - File or directory not found. Like, what? But then I’d go to the root: http://10.1.2.09:7004/Ecom
And the app would load fine. After that, the /Accounts/Login link would magically work again. Maddening, right? It only happened first thing in the day, when nobody had touched the app overnight. Total cold-start BS.
What’s Actually Happening?
Turns out, IIS is lazy. If your app sits idle too long, IIS unloads it to save resources. So when that first morning request comes in—especially to a deep link like /Accounts/Login—the app’s not fully awake yet. You get a 404, a delay, or just a bad vibe for whoever’s trying to use it. Lame user experience.
How I Fixed It (No Code, I Swear)
I didn’t touch a single line of C# code or mess with the app logic. The fix was all in how IIS handles your app when no one’s using it.
Here’s what I did:
Step 1: Open IIS Manager
This is the tool Windows uses to host web apps.
Just hit the Start menu → type IIS
→ open "Internet Information Services (IIS) Manager".
Step 2: Find Your Website
In the left panel, you’ll see a tree view.
Open the Sites node → click on your website (for me, it was something like CCWServer
).
Step 3: Go to Advanced Settings
Right-click your website → click Manage Website → Advanced Settings.
This opens a window with a lot of options (don’t worry, we only need one).
Step 4: Turn On "Preload Enabled"
Scroll down in the settings until you find Preload Enabled.
Set that to True
.
What This Actually Does
Normally, IIS only "wakes up" your app when the first user opens it — kind of like putting it to sleep when no one's using it to save memory.
That causes a delay... or even 404s on deep URLs (like /Accounts/Login
) if the app isn’t ready.
By enabling Preload, you’re telling IIS:
“Hey, load my app in the background as soon as the server starts — don’t wait for a user to hit the URL.”
So your app is always ready to serve, no warm-up needed, and no weird morning errors.
No tweaks to Startup.cs, no fiddling with web.config, no messing with appsettings.json. Just a checkbox and done.
The Result
No more morning 404s
Application stays warm
Users hit deep URLs directly with no issues
No code changes, no app restarts, no hacky solutions
Pro Tips
If you’re facing a similar issue:
Use Application Pool > Advanced Settings → Set
Start Mode = AlwaysRunning
Set
Idle Timeout = 0
to prevent sleepingEnable Preload at the site level
All this combined = blazing fast first load, always-on performance.
Real Talk
Sometimes you don’t need to sling code to fix annoying problems like this. A little IIS know-how can save you hours of pain. If you’ve run into weird deployment issues like this or found other slick fixes, drop a comment—I’m curious what else is out there. Let’s keep learning this stuff together.
Subscribe to my newsletter
Read articles from Pratham Ghosalkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
