Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 151–175 of 3281

Career & HR topics

By tech stack

Popular tracks

Mid PDF
Differences between terminal middleware vs non-terminal?

Short answer: 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…

ASP.NET Core Read answer
Mid PDF
Can filters modify the action arguments?

Short answer: Yes—action filters have full access to ActionArguments. Real-world example (ShopNest) ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threadi…

ASP.NET Core Read answer
Mid PDF
How to integrate authentication/authorization middleware

Short answer: app.UseAuthentication(); // Validates user identity app.UseAuthorization(); // Applies policies/roles Order matters: must be after routing but before endpoints. app.UseRouting(); app.UseAuthentication(); ap…

ASP.NET Core Read answer
Mid PDF
Summary & Key Takeaways?

Short answer: 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…

ASP.NET Core Read answer
Mid PDF
How do exception filters differ from middleware exception handling?

Short answer: Exception filters only catch exceptions from MVC actions; middleware catches exceptions from the entire pipeline. Real-world example (ShopNest) ShopNest pipeline order matters: exception handling → HTTPS →…

ASP.NET Core Read answer
Mid PDF
How to enable and configure CORS via middleware builder.Services.AddCors(options => { options.AddPolicy("MyPolicy", policy => { policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); });

Short answer: pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. pp.UseCors("MyPolicy"); Must be placed before…

ASP.NET Core Read answer
Mid PDF
How to enable and configure CORS via middleware

Short answer: builder.Services.AddCors(options => { options.AddPolicy("MyPolicy", policy => { policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); app.UseCors("MyPolicy"); Must…

ASP.NET Core Read answer
Mid PDF
How to apply a filter globally?

Short answer: Use: services.AddControllers(options => { options.Filters.Add(typeof(AuditLogFilter)); }); Advanced Level Example code Use: services.AddControllers(options => { options.Filters.Add(typeof(AuditLogFilt…

ASP.NET Core Read answer
Mid PDF
Using middleware for logging or performance (e.g. measuring 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();

Short answer: wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI) wait _next(conte…

ASP.NET Core Read answer
Mid PDF
Using middleware for logging or performance (e.g. measuring?

Short answer: execution time) Example custom middleware to measure time: public class TimingMiddleware Example code { private readonly RequestDelegate _next; public TimingMiddleware(RequestDelegate next) => _next = ne…

ASP.NET Core Read answer
Mid PDF
What are Endpoint Filters?

Short answer: Filters specifically built for Minimal APIs (introduced in ASP.NET Core 7). Real-world example (ShopNest) A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same…

ASP.NET Core Read answer
Mid PDF
ASP.NET Core’s built-in DI container: capabilities and limitations?

Short answer: ✅ Capabilities: Constructor injection Lifetime management (Transient, Scoped, Singleton) Supports IEnumerable<T>, IServiceProvider, and open generics ⚠ Limitations: No support for named registrations…

ASP.NET Core Read answer
Mid PDF
Different service lifetimes: Transient, Scoped, Singleton?

Short 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 Logg…

ASP.NET Core Read answer
Mid PDF
Explain filter ordering with an example.

Short answer: Lower order executes first on entry but last on exit—like nested layers. Real-world example (ShopNest) A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rul…

ASP.NET Core Read answer
Mid PDF
How to register services in ConfigureServices

Short answer: public void ConfigureServices(IServiceCollection services) { services.AddTransient<IMyService, MyService>(); services.AddScoped<IRepository, Repository>(); services.AddSingleton<ILoggerServic…

ASP.NET Core Read answer
Mid PDF
How do you test a filter that modifies HttpContext?

Short answer: Use a mocked HttpContext and assert on changes. Real-world example (ShopNest) ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.…

ASP.NET Core Read answer
Mid PDF
How to resolve dependencies in controllers, razor pages, middleware

Short answer: Controllers: Constructor injection Razor Pages: Constructor injection in PageModel Middleware: Inject via constructor or use IApplicationBuilder.ApplicationServices Real-world example (ShopNest) ShopNest pi…

ASP.NET Core Read answer
Mid PDF
How to prevent a filter from affecting certain actions?

Short answer: Use [SkipFilter] custom attribute or exclude via filter predicates. Real-world example (ShopNest) A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for…

ASP.NET Core Read answer
Mid PDF
Constructor injection vs property injection (and which is supported)?

Short answer: Constructor Injection: Supported and preferred in ASP.NET Core. Property Injection: Not supported natively in built-in DI; can be achieved via custom logic or 3rd-party containers. ✅ Use constructor injecti…

ASP.NET Core Read answer
Mid PDF
Can filters be middleware?

Short answer: No. But middleware can replace some filter use cases. Say this in the interview Define — one clear sentence (the short answer above). Example — relate it to a project like ShopNest or your real work. Trade-…

ASP.NET Core Read answer
Mid PDF
Using IServiceProvider / IServiceScopeFactory?

Short answer: IServiceProvider: Resolves services manually. IServiceScopeFactory: Creates a new DI scope (useful for background tasks). using (var scope = serviceScopeFactory.CreateScope()) Example code { var scopedServi…

ASP.NET Core Read answer
Mid PDF
Describe a scenario requiring both middleware and filters.

Short answer: Middleware logs incoming requests; action filter logs controller-level execution. Real-world example (ShopNest) ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints…

ASP.NET Core Read answer
Mid PDF
How scoped services behave in background tasks vs request scope

Short answer: Scoped services are tied to the HTTP request lifecycle. In background tasks, you must manually create a scope using IServiceScopeFactory to resolve scoped services safely. Real-world example (ShopNest) Shop…

ASP.NET Core Read answer
Mid PDF
Explain async pitfalls in filters.

Short answer: Mixing sync & async can cause deadlocks. Prefer async filters. Real-world example (ShopNest) A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule…

ASP.NET Core Read answer
Mid PDF
How to override default DI behavior (e.g., remove or replace services)

Short answer: To replace: services.AddSingleton<IService, CustomImplementation>(); To remove: var descriptor = services.First(x => x.ServiceType == typeof(IMyService)); services.Remove(descriptor); Real-world ex…

ASP.NET Core Read answer

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: 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"); });

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Yes—action filters have full access to ActionArguments.

Real-world example (ShopNest)

ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: app.UseAuthentication(); // Validates user identity app.UseAuthorization(); // Applies policies/roles Order matters: must be after routing but before endpoints. app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(...);

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: 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 error handling. Use DI for scalable, clean, testable filter implementations. Filters shine in enterprise applications: auditing, authorization, and response shaping.

Real-world example (ShopNest)

A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Exception filters only catch exceptions from MVC actions; middleware catches exceptions from the entire pipeline.

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. pp.UseCors("MyPolicy"); Must be placed before routing/endpoints. pp.UseCors("MyPolicy"); Must be placed before routing/endpoints.

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: builder.Services.AddCors(options => { options.AddPolicy("MyPolicy", policy => { policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); app.UseCors("MyPolicy"); Must be placed before routing/endpoints.

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Use: services.AddControllers(options => { options.Filters.Add(typeof(AuditLogFilter)); }); Advanced Level

Example code

Use: services.AddControllers(options => { options.Filters.Add(typeof(AuditLogFilter)); }); Advanced Level

Real-world example (ShopNest)

A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI) wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency… Injection (DI) wait… _next(context); sw.Stop(); Console.WriteLine($"Request took…

Explain a bit more

{sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI) wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency… Injection (DI)

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: execution time) Example custom middleware to measure time: public class TimingMiddleware

Example code

{
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)

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Filters specifically built for Minimal APIs (introduced in ASP.NET Core 7).

Real-world example (ShopNest)

A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: ✅ Capabilities: Constructor injection Lifetime management (Transient, Scoped, Singleton) Supports IEnumerable<T>, IServiceProvider, and open generics ⚠ Limitations: No support for named registrations Limited property injection Basic feature set compared to Autofac or other 3rd-party containers

Real-world example (ShopNest)

ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short 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

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Lower order executes first on entry but last on exit—like nested layers.

Real-world example (ShopNest)

A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: public void ConfigureServices(IServiceCollection services) { services.AddTransient<IMyService, MyService>(); services.AddScoped<IRepository, Repository>(); services.AddSingleton<ILoggerService, LoggerService>(); }

Example code

public void ConfigureServices(IServiceCollection services)
{ services.AddTransient<IMyService, MyService>(); services.AddScoped<IRepository, Repository>(); services.AddSingleton<ILoggerService, LoggerService>(); }

Real-world example (ShopNest)

A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Use a mocked HttpContext and assert on changes.

Real-world example (ShopNest)

ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Controllers: Constructor injection Razor Pages: Constructor injection in PageModel Middleware: Inject via constructor or use IApplicationBuilder.ApplicationServices

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Use [SkipFilter] custom attribute or exclude via filter predicates.

Real-world example (ShopNest)

A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Constructor Injection: Supported and preferred in ASP.NET Core. Property Injection: Not supported natively in built-in DI; can be achieved via custom logic or 3rd-party containers. ✅ Use constructor injection for immutability and clarity.

Example code

Constructor Injection: Supported and preferred in ASP.NET Core. Property Injection: Not supported natively in built-in DI; can be achieved via custom logic or 3rd-party containers. ✅ Use constructor injection for immutability and clarity.

Real-world example (ShopNest)

A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: No. But middleware can replace some filter use cases.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: IServiceProvider: Resolves services manually. IServiceScopeFactory: Creates a new DI scope (useful for background tasks). using (var scope = serviceScopeFactory.CreateScope())

Example code

{
var scopedService = scope.ServiceProvider.GetRequiredService<IMyScopedService>(); }

Real-world example (ShopNest)

A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Middleware logs incoming requests; action filter logs controller-level execution.

Real-world example (ShopNest)

ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Scoped services are tied to the HTTP request lifecycle. In background tasks, you must manually create a scope using IServiceScopeFactory to resolve scoped services safely.

Real-world example (ShopNest)

ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: Mixing sync &amp; async can cause deadlocks. Prefer async filters.

Real-world example (ShopNest)

A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core

Short answer: To replace: services.AddSingleton<IService, CustomImplementation>(); To remove: var descriptor = services.First(x => x.ServiceType == typeof(IMyService)); services.Remove(descriptor);

Real-world example (ShopNest)

ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details