Your ASP.NET Core application works perfectly on your local machineβ¦
But the moment you deploy it β everything breaks.
No errors. No warnings. Just frustration.
If you've faced this, you're not alone. In this article, I'll show you 7 real production mistakes developers make β and how to fix them.
π₯ 1. Missing Configuration in Production
This is one of the most common mistakes.
On your local machine, everything works because you're using:
appsettings.Development.json
But on the server, ASP.NET Core uses:
appsettings.Production.json
π If your connection string or settings are missing there, your app will fail silently.
β
Fix
Make sure production config exists:
{
"ConnectionStrings": {
"DefaultConnection": "Your_Production_DB_String"
}
}
Also verify environment:
ASPNETCORE_ENVIRONMENT=Production
2. Database Connection Issues
Your local DB works fine, but production fails.
Why?
β
Fix
π Example:
"Server=192.168.1.10;Database=MyDb;User Id=sa;Password=123;"
3. Static Files Not Loading (CSS/JS Missing)
Your UI looks broken after deployment.
π Reason:
You forgot to enable static files middleware.
β Wrong
app.UseRouting();
β
Correct
app.UseStaticFiles();
app.UseRouting();
4. Session Not Working
Session works locally but not on server.
π Common mistake:
You added services but forgot middleware.
β Wrong
builder.Services.AddSession();
β
Correct
builder.Services.AddSession();
app.UseSession();
Also ensure:
app.UseRouting();
app.UseSession();
app.UseEndpoints(...);
5. Case Sensitivity Issues (Linux Server Problem)
Works on Windows⦠fails on Linux.
π Example:
return View("Index");
But your file is:
index.cshtml
π Linux is case-sensitive.
β
Fix
Match exact file names
Follow consistent naming
6. Missing Dependencies / DLLs
App builds locally but crashes on server.
π Reason:
Some DLLs not published
NuGet packages missing
β
Fix
Always publish properly:
dotnet publish -c Release
Or use Visual Studio:
π Publish β Folder / IIS / Azure
7. No Proper Error Logging
Worst mistake.
π You donβt see errors because:
Logging not configured
Exceptions swallowed
β
Fix
Enable logging:
builder.Logging.AddConsole();
Use try-catch:
try
{
// your code
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
π Better: Use Serilog or NLog for production
β
Final Thoughts
If your app works locally but fails in production, itβs usually not magic β itβs one of these mistakes.
βοΈ Quick Checklist
βοΈ Correct environment config
βοΈ Valid database connection
βοΈ Static files enabled
βοΈ Session configured
βοΈ Case-sensitive file names
βοΈ Proper publish process
βοΈ Logging enabled
Closing
Production issues are frustrating, but theyβre also where real learning happens.
Stop guessing. Start debugging smart.