Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Answer: sync filters implement IAsyncActionFilter and support await, improving scalability. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainabili…
🏦 Fintech API – Global Exception Filter Ensures consistent error envelopes across microservices. 🛠 Microservices – Audit Logging Tracks when sensitive controller actions are executed. 👮 Role-based Authorization Custom…
custom page or handler. Example: if (env.IsDevelopment()) pp.UseDeveloperExceptionPage(); else pp.UseExceptionHandler("/Error"); Or inline: pp.UseExceptionHandler(errorApp => { errorApp.Run(async context => { conte…
(UseExceptionHandler, UseDeveloperExceptionPage) UseDeveloperExceptionPage() shows detailed errors (development only). UseExceptionHandler("/Error") handles errors in production with a custom page or handler. Example: if…
Yes. They form a pipeline based on their defined order. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainability, security, cost) When you would a…
Answer: Filters execute per controller action → use sparingly. Avoid heavy DB calls. Avoid creating new HttpClients or DbContexts inside filters. Prefer asynchronous filters. What interviewers expect A clear definition t…
Answer: pp.UseHttpsRedirection(); dd early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or ppsettings.json. What interviewers expect A clear definition tied to ASP.NET Cor…
Answer: Redirects HTTP requests to HTTPS. app.UseHttpsRedirection(); Add early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or appsettings.json. What interviewers expect A…
Use: ActionExecutingContext mocks ActionExecutedContext mocks DefaultHttpContext var httpContext = new DefaultHttpContext(); var context = new ActionExecutingContext(...); Focus tests on: Expected results Short-circuitin…
pp.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "MyFiles")), RequestPath = "/Files", OnPrepareResponse = ctx => { ctx.Context.Response.Headers.Append…
Mistake Fix Doing authentication inside action filters Use authorization filters Performing heavy logic Move to middleware Not registering filters as services Use DI for maintainability Returning inconsistent error messa…
Answer: pp.Run(async ctx => { wait ctx.Response.WriteAsync("This ends the pipeline"); }); What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintain…
middleware Type Description Terminal Ends the pipeline. Doesn’t call next(). E.g., app.Run() Non-Termi nal Calls next() and allows other middlewares to run after it. E.g., app.Use() Terminal middleware: app.Run(async ctx…
Yes—action filters have full access to ActionArguments. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainability, security, cost) When you would a…
pp.UseAuthentication(); // Validates user identity pp.UseAuthorization(); // Applies policies/roles Order matters: must be after routing but before endpoints. pp.UseRouting(); pp.UseAuthentication(); pp.UseAuthorization(…
Filters provide clean, reusable cross-cutting logic for MVC pipelines. Use the right filter type for the right stage. Prefer middleware when you don’t need controller context. Exception filters are best for consistent er…
Answer: Exception filters only catch exceptions from MVC actions; middleware catches exceptions from the entire pipeline. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-of…
pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainability, security, cost) When yo…
Answer: builder.Services.AddCors(options => options.AddPolicy("MyPolicy", policy => policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); app.UseCors("MyPolicy"); Must be placed before routing/e…
Answer: wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI) What interviewers expect…
execution time) Example custom middleware to measure time: public class TimingMiddleware private readonly RequestDelegate _next; public TimingMiddleware(RequestDelegate next) => _next = next; public async Task InvokeA…
Filters specifically built for Minimal APIs (introduced in ASP.NET Core 7). What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainability, security, co…
✅ Capabilities: Constructor injection Lifetime management (Transient, Scoped, Singleton) Supports IEnumerable<T>, IServiceProvider, and open generics ⚠ Limitations: No support for named registrations Limited proper…
Answer: Lifetime Description Use Case Example Transient New instance every time Lightweight stateless services Scoped One instance per request Database context, UoW Singleto One instance for the app's lifetime Logging, C…
Lower order executes first on entry but last on exit—like nested layers. What interviewers expect A clear definition tied to ASP.NET Core in ASP.NET Core projects Trade-offs (performance, maintainability, security, cost)…
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: sync filters implement IAsyncActionFilter and support await, improving scalability.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
🏦 Fintech API – Global Exception Filter
Ensures consistent error envelopes across microservices.
🛠 Microservices – Audit Logging
Tracks when sensitive controller actions are executed.
👮 Role-based Authorization
Custom authorization filter validating role claims dynamically.
🚀 Performance Profiling
Times how long each controller method takes.
public class ProfilingFilter : IActionFilter
{
private Stopwatch _watch;
public void OnActionExecuting(ActionExecutingContext context)
{
_watch = Stopwatch.StartNew();
}
public void OnActionExecuted(ActionExecutedContext context)
{
_watch.Stop();
Console.WriteLine($"Action took {_watch.ElapsedMilliseconds}
ms");
}
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
custom page or handler.
Example:
if (env.IsDevelopment())
pp.UseDeveloperExceptionPage();
else
pp.UseExceptionHandler("/Error");
Or inline:
pp.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = 500;
wait context.Response.WriteAsync("An error
occurred");
});
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
(UseExceptionHandler, UseDeveloperExceptionPage)
only).
a custom page or handler.
Example:
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Error");
Or inline:
app.UseExceptionHandler(errorApp =>
errorApp.Run(async context =>
context.Response.StatusCode = 500;
await context.Response.WriteAsync("An error
occurred");
});
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes. They form a pipeline based on their defined order.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Filters execute per controller action → use sparingly. Avoid heavy DB calls. Avoid creating new HttpClients or DbContexts inside filters. Prefer asynchronous filters.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseHttpsRedirection(); dd early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or ppsettings.json.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Redirects HTTP requests to HTTPS. app.UseHttpsRedirection(); Add early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or appsettings.json.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use:
var httpContext = new DefaultHttpContext();
var context = new ActionExecutingContext(...);
Focus tests on:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseStaticFiles(new StaticFileOptions
{
FileProvider = new
PhysicalFileProvider(Path.Combine(env.ContentRootPath,
"MyFiles")),
RequestPath = "/Files",
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Append("Cache-Control",
"public,max-age=600");
}
});
For directory browsing:
pp.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider("path"),
RequestPath = "/browse"
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Mistake Fix
Doing authentication inside action filters Use authorization filters
Performing heavy logic Move to middleware
Not registering filters as services Use DI for maintainability
Returning inconsistent error messages Handle errors via global exception filterASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.Run(async ctx => { wait ctx.Response.WriteAsync("This ends the pipeline"); });
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
middleware
Type Description
Terminal Ends the pipeline. Doesn’t call next(). E.g., app.Run()
Non-Termi
nal
Calls next() and allows other middlewares to run after it.
E.g., app.Use()
Terminal middleware:
app.Run(async ctx => {
await ctx.Response.WriteAsync("This ends the pipeline");
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes—action filters have full access to ActionArguments.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseAuthentication(); // Validates user identity
pp.UseAuthorization(); // Applies policies/roles
Order matters: must be after routing but before endpoints.
pp.UseRouting();
pp.UseAuthentication();
pp.UseAuthorization();
pp.UseEndpoints(...);
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Exception filters only catch exceptions from MVC actions; middleware catches exceptions from the entire pipeline.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseCors("MyPolicy"); Must be placed before routing/endpoints.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: builder.Services.AddCors(options => options.AddPolicy("MyPolicy", policy => policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); app.UseCors("MyPolicy"); Must be placed before routing/endpoints.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI)
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
execution time)
Example custom middleware to measure time:
public class TimingMiddleware
private readonly RequestDelegate _next;
public TimingMiddleware(RequestDelegate next) => _next =
next;
public async Task InvokeAsync(HttpContext context)
var sw = Stopwatch.StartNew();
await _next(context);
sw.Stop();
Console.WriteLine($"Request took
{sw.ElapsedMilliseconds} ms");
Register:
app.UseMiddleware<TimingMiddleware>();
Dependency Injection (DI)
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Filters specifically built for Minimal APIs (introduced in ASP.NET Core 7).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ Capabilities:
⚠ Limitations:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Lifetime Description Use Case Example Transient New instance every time Lightweight stateless services Scoped One instance per request Database context, UoW Singleto One instance for the app's lifetime Logging, Config access
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Lower order executes first on entry but last on exit—like nested layers.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.