Core .NET concepts you must nail in a senior interview
1. How do .NET Framework and .NET Core differ in async programming?
.NET Framework captures the SynchronizationContext, especially in UI apps. This can cause deadlocks if you block with .Result
or .Wait()
.
.NET Core avoids context capture in server apps, making async/await
more scalable and less prone to deadlocks.
// .NET Core - safe async
await httpClient.GetAsync("https://api.com");
Use ConfigureAwait(false)
in library code to avoid unnecessary context capture.
2. What’s the difference between Startup.cs and Program.cs?
In .NET Core:
-
Program.cs
is the entry point. It builds the host. -
Startup.cs
configures services and middleware.
In .NET 6+, they’re merged:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
Use separate files for large apps to maintain clarity and separation of concerns.
3. How do you explain cookies to a non-technical stakeholder?
Cookies are like name tags websites give you. They help the site remember who you are—like keeping you logged in or remembering your preferences. They’re stored on your device and sent back to the site automatically.
4. How does a developer access cookie values from the server?
var theme = Request.Cookies["UserTheme"];
if (theme != null) {
return Content($"Theme: {theme}");
}
Always check for null. Use HttpOnly
and Secure
flags for sensitive data.
5. How do you debug intermittent site crashes?
You don’t guess—you capture, analyze, and isolate.
- Capture: Enable crash dumps, use Application Insights, Serilog, or ELK.
- Analyze: Look for memory leaks, thread starvation, unhandled exceptions.
- Diagnose: Attach Visual Studio or dotTrace.
- Fix: Refactor blocking calls, add retries, validate with load tests.
Use correlation IDs and structured logging to trace across services.
6. What encoding does .NET use by default?
- .NET Core: UTF-8
- .NET Framework: System-dependent ANSI
Always specify encoding explicitly:
File.WriteAllText("data.txt", content, Encoding.UTF8);
This avoids corruption and ensures cross-platform consistency.
Top comments (0)