Interview Q&A

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

4616 total questions 4516 technical 100 career & HR 4346 from PDF library

Showing 51–63 of 63

Popular tracks

Mid PDF
User secrets (in Development) These are merged in order — later values override earlier ones. 🧱 2. What are configuration providers?

Configuration providers are components that load configuration data from various sources. Built-in Providers: JSON files (appsettings.json) Environment variables Command-line arguments In-memory collections Azure Key Vau…

Mid PDF
Exception (special case — when an error occurs) Tip: Filters with a lower Order value run first. Example: Follow : [MyActionFilter(Order = 1)] [MyLoggingFilter(Order = 2)] ⚒ 14. How do you create a custom action filter?

public class LogActionFilter : ActionFilterAttribute public override void OnActionExecuting(ActionExecutingContext context) Console.WriteLine($"Action: {context.ActionDescriptor.DisplayName}"); Use it: [LogActionFilter]…

Mid PDF
Hangfire or Quartz.NET for Background Jobs Hangfire Example: app.UseHangfireDashboard(); RecurringJob.AddOrUpdate(() => Console.WriteLine("Recurring job"), Cron.Daily); Quartz.NET: Supports cron-like scheduling and clustered execution.

Answer: Hangfire or Quartz.NET for Background Jobs Hangfire Example: app.UseHangfireDashboard(); RecurringJob.AddOrUpdate(() => Console.WriteLine("Recurring job"), Cron.Daily); Quartz.NET: Supports cron-like sched…

Mid PDF
How to Test Minimal APIs? Answer: Minimal APIs are tested using WebApplicationFactory or TestServer. Example: var factory = new WebApplicationFactory<Program>(); var client = factory.CreateClient(); var response = await client.GetAsync("/products"); var products = await response.Content.ReadFromJsonAsync<List<Product>>(); Assert.NotEmpty(products);

How to Test Minimal APIs? Answer: Minimal APIs are tested using WebApplicationFactory or TestServer. Example: var factory = new WebApplicationFactory&lt;Program&gt;(); var client = factory.CreateClient(); var response =…

Mid PDF
Health Checking in ASP.NET Core builder.Services.AddHealthChecks() .AddSqlServer(connectionString) .AddCheck<CustomHealthCheck>("CustomCheck"); app.MapHealthChecks("/health"); Custom Health Check Example: public class CustomHealthCheck : IHealthCheck { public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken token) => Task.FromResult(HealthCheckResult.Healthy("Everything OK")); }

Health Checking in ASP.NET Core builder.Services.AddHealthChecks() .AddSqlServer(connectionString) .AddCheck&lt;CustomHealthCheck&gt;("CustomCheck"); app.MapHealthChecks("/health"); Custom Health Check Example: public cl…

Mid PDF
How to Use Serilog or NLog? Serilog Example (Program.cs): builder.Host.UseSerilog((ctx, lc) => lc .WriteTo.Console() .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day) ); NLog Example: 1. Install NLog.Extensions.Logging package 2. Add NLog.config file 3. Configure in Program.cs: builder.Logging.ClearProviders(); builder.Logging.SetMinimumLevel(LogLevel.Information); builder.Host.UseNLog(); ✅ Both support structured logging, sinks, filtering, and rolling files.

How to Use Serilog or NLog? Serilog Example (Program.cs): builder.Host.UseSerilog((ctx, lc) =&gt; lc .WriteTo.Console() .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day) ); NLog Example: Install NLog.E…

Mid PDF
What Frameworks Are Commonly Used? Answer: ● xUnit – Popular, lightweight, supports parallel testing. ● NUnit – Rich assertion library. ● MSTest – Microsoft-supported, integrated in Visual Studio. Most modern ASP.NET Core projects use xUnit + Moq.

What Frameworks Are Commonly Used? Answer: xUnit – Popular, lightweight, supports parallel testing. NUnit – Rich assertion library. MSTest – Microsoft-supported, integrated in Visual Studio. Most modern ASP.NET Core proj…

Junior PDF
Deploy self-contained trimmed builds for smaller binaries. Example for build optimization: dotnet publish -c Release /p:PublishTrimmed=true /p:ReadyToRun=true 🔐 10. What is Data Protection in ASP.NET Core?

ASP.NET Core Data Protection API provides secure cryptographic APIs for: Encrypting cookies and tokens Protecting form data Persisting secure keys (across app restarts) Setup: builder.Services.AddDataProtection() .Persis…

Junior PDF
Deploy self-contained trimmed builds for smaller binaries. Example for build optimization: dotnet publish -c Release /p:PublishTrimmed=true /p:ReadyToRun=true 🔐 10. What is Data Protection in ASP.NET Core? Follow :

ASP.NET Core Data Protection API provides secure cryptographic APIs for: Encrypting cookies and tokens Protecting form data Persisting secure keys (across app restarts) Setup: builder.Services.AddDataProtection() .Persis…

Mid PDF
Profile queries with ToQueryString(). Example: var data = _context.Products.AsNoTracking().Select(p => new { p.Name, p.Price }).ToList(); ⚡ 18. How to use compiled queries?

Compiled queries improve performance by caching query translation. Example: private static readonly Func&lt;AppDbContext, decimal, IEnumerable&lt;Product&gt;&gt; _getExpensiveProducts = EF.CompileQuery((AppDbContext ctx,…

Mid PDF
Rate Limiting Middleware in .NET 8 builder.Services.AddRateLimiter(options => { options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(httpContext => RateLimitPartition.GetFixedWindowLimiter(httpContext.Connection.Remo teIpAddress?.ToString()!, _ => new FixedWindowRateLimiterOptions { PermitLimit = 10, Window = TimeSpan.FromMinutes(1), QueueLimit = 2 })); }); app.UseRateLimiter(); ✅ Helps protect APIs from abuse or DoS attacks.

Rate Limiting Middleware in .NET 8 builder.Services.AddRateLimiter(options =&gt; { options.GlobalLimiter = PartitionedRateLimiter.Create&lt;HttpContext, string&gt;(httpContext =&gt; RateLimitPartition.GetFixedWindowLimit…

Mid PDF
How to Enable Application Insights? Answer: Application Insights provides monitoring, telemetry, and tracing. Setup: builder.Services.AddApplicationInsightsTelemetry(builder.Configurati on["APPINSIGHTS_INSTRUMENTATIONKEY"]); Features: ● Track requests, exceptions, and dependencies ● Live metrics and dashboards ● Custom events and telemetry

How to Enable Application Insights? Answer: Application Insights provides monitoring, telemetry, and tracing. Setup: builder.Services.AddApplicationInsightsTelemetry(builder.Configurati on["APPINSIGHTS_INSTRUMENTATIONKEY…

Mid PDF
How to Use Moq for Mocking Dependencies? Answer: Moq creates fake implementations of interfaces to control behavior during tests. Example: var mockRepo = new Mock<IProductRepository>(); mockRepo.Setup(x => x.GetAll()).Returns(new List<Product> { new Product { Id = 1, Name = "Laptop" } }); var service = new ProductService(mockRepo.Object); var products = service.GetAll(); Assert.Single(products); ✅ Use .Setup(), .Verify(), and .Returns() to simulate behavior.

How to Use Moq for Mocking Dependencies? Answer: Moq creates fake implementations of interfaces to control behavior during tests. Example: var mockRepo = new Mock&lt;IProductRepository&gt;(); mockRepo.Setup(x =&gt; x.Get…

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

Configuration providers are components that load configuration data from various

sources.

Built-in Providers:

  • JSON files (appsettings.json)
  • Environment variables
  • Command-line arguments
  • In-memory collections
  • Azure Key Vault
  • User Secrets (for local dev)
  • Custom providers (you can build your own)

Example:

builder.Configuration

.AddJsonFile("appsettings.json")

.AddEnvironmentVariables()

.AddCommandLine(args);

Each provider plugs into the same configuration system, so you can access everything via

IConfiguration.

🔐 3. How do you manage secrets in development?

In development, never store passwords, API keys, or connection strings in code or

ppsettings.json.

Use User Secrets — a safe way to store secrets outside the project tree.

🧰 4. What is User Secrets in ASP.NET Core?

User Secrets are a local, developer-only configuration storage that keeps sensitive data

out of source control.

Setup:

Enable secrets:

dotnet user-secrets init

Permalink & share

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

public class LogActionFilter : ActionFilterAttribute

public override void OnActionExecuting(ActionExecutingContext

context)

Console.WriteLine($"Action:

{context.ActionDescriptor.DisplayName}");

Use it:

[LogActionFilter]

public IActionResult Index() => View();

📤 15. How do you pass data from controller to view?

You can use:

Permalink & share

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

Answer: Hangfire or Quartz.NET for Background Jobs Hangfire Example: app.UseHangfireDashboard(); RecurringJob.AddOrUpdate(() =&gt; Console.WriteLine("Recurring job"), Cron.Daily); Quartz.NET: Supports cron-like scheduling and clustered execution.

What interviewers expect

  • A clear definition tied to MVC in ASP.NET Core MVC projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

In a production ASP.NET Core MVC 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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in ASP.NET Core MVC architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

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

How to Test Minimal APIs?

Answer:

Minimal APIs are tested using WebApplicationFactory or TestServer.

Example:

var factory = new WebApplicationFactory<Program>();
var client = factory.CreateClient();
var response = await client.GetAsync("/products");
var products = await

response.Content.ReadFromJsonAsync<List<Product>>();

Assert.NotEmpty(products);

Permalink & share

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

Health Checking in ASP.NET Core

builder.Services.AddHealthChecks()

.AddSqlServer(connectionString)

.AddCheck<CustomHealthCheck>("CustomCheck");

app.MapHealthChecks("/health");

Custom Health Check Example:

public class CustomHealthCheck : IHealthCheck
{
public Task<HealthCheckResult>

CheckHealthAsync(HealthCheckContext context, CancellationToken

token) =>

Task.FromResult(HealthCheckResult.Healthy("Everything OK"));

}
Permalink & share

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

How to Use Serilog or NLog?

Serilog Example (Program.cs):

builder.Host.UseSerilog((ctx, lc) => lc

.WriteTo.Console()

.WriteTo.File("logs/log-.txt", rollingInterval:

RollingInterval.Day)

);

NLog Example:

  • Install NLog.Extensions.Logging package
  • Add NLog.config file
  • Configure in Program.cs:

builder.Logging.ClearProviders();

builder.Logging.SetMinimumLevel(LogLevel.Information);

builder.Host.UseNLog();

✅ Both support structured logging, sinks, filtering, and rolling files.

Permalink & share

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

What Frameworks Are Commonly Used?

Answer:

  • xUnit – Popular, lightweight, supports parallel testing.
  • NUnit – Rich assertion library.
  • MSTest – Microsoft-supported, integrated in Visual Studio.

Most modern ASP.NET Core projects use xUnit + Moq.

Permalink & share

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

ASP.NET Core Data Protection API provides secure cryptographic APIs for:

  • Encrypting cookies and tokens
  • Protecting form data
  • Persisting secure keys (across app restarts)

Setup:

builder.Services.AddDataProtection()

.PersistKeysToFileSystem(new DirectoryInfo(@"c:\keys"))

.SetApplicationName("MyApp");

You can use it directly:

var protector = _provider.CreateProtector("MyPurpose");
var encrypted = protector.Protect("secret-data");
var decrypted = protector.Unprotect(encrypted);

✅ Data Protection is the backbone for:

  • Cookie Authentication
  • CSRF Tokens
  • TempData encryption

🧠 Summary

Concept Description Best For

In-memory caching Stores data in server memory Single-server or dev

Distributed caching Shared cache (Redis, SQL) Scalable apps

Response caching Caches HTTP responses Public/static data

Output caching (.NET 8) Advanced, user-aware

caching

Dynamic APIs

Response compression Gzip/Brotli for responses Large payloads

sync/await Non-blocking I/O High concurrency

Startup optimization Faster app boot Cloud apps

Data protection Encrypt sensitive data Cookies, tokens,

forms

Testing

How to Unit Test Controllers?

Unit testing controllers ensures your business logic in action methods works correctly

without hitting the database or HTTP pipeline.

Steps:

Permalink & share

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

ASP.NET Core Data Protection API provides secure cryptographic APIs for:

  • Encrypting cookies and tokens
  • Protecting form data
  • Persisting secure keys (across app restarts)

Setup:

builder.Services.AddDataProtection()

.PersistKeysToFileSystem(new DirectoryInfo(@"c:\keys"))

.SetApplicationName("MyApp");

You can use it directly:

var protector = _provider.CreateProtector("MyPurpose");

var encrypted = protector.Protect("secret-data");

var decrypted = protector.Unprotect(encrypted);

✅ Data Protection is the backbone for:

  • Cookie Authentication
  • CSRF Tokens
  • TempData encryption

🧠 Summary

Concept Description Best For

In-memory caching Stores data in server memory Single-server or dev

Distributed caching Shared cache (Redis, SQL) Scalable apps

Response caching Caches HTTP responses Public/static data

Follow :

Output caching (.NET 8) Advanced, user-aware

caching

Dynamic APIs

Response compression Gzip/Brotli for responses Large payloads

Async/await Non-blocking I/O High concurrency

Startup optimization Faster app boot Cloud apps

Data protection Encrypt sensitive data Cookies, tokens,

forms

Testing

How to Unit Test Controllers?

Unit testing controllers ensures your business logic in action methods works correctly

without hitting the database or HTTP pipeline.

Steps:

Permalink & share

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

Compiled queries improve performance by caching query translation.

Example:

private static readonly Func<AppDbContext, decimal,

IEnumerable<Product>> _getExpensiveProducts =

EF.CompileQuery((AppDbContext ctx, decimal price) =>

ctx.Products.Where(p => p.Price > price));
var result = _getExpensiveProducts(_context, 1000);

🔍 19. What is global query filtering?

It allows you to apply filters automatically to all queries for a given entity — useful for soft

deletes or multi-tenancy.

Example:

modelBuilder.Entity<Product>()

.HasQueryFilter(p => !p.IsDeleted);

ll queries automatically exclude deleted products.

🌐 20. How do you handle database connection

pooling?

Connection pooling is handled automatically by ADO.NET and EF Core providers.

Each new DbContext reuses existing connections from the pool to reduce overhead.

For fine control:

options.UseSqlServer(connectionString, opt =>

opt.EnableRetryOnFailure());

Tips:

  • Keep DbContexts short-lived (Scoped lifetime).
  • Avoid keeping connections open unnecessarily.
  • For high-traffic apps, tune pool

settings in the connection string:

Max Pool Size=200; Min
Pool Size=5;

uthentication & Authorization

Permalink & share

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

Rate Limiting Middleware in .NET 8

builder.Services.AddRateLimiter(options =>

{

options.GlobalLimiter =

PartitionedRateLimiter.Create<HttpContext, string>(httpContext =>

RateLimitPartition.GetFixedWindowLimiter(httpContext.Connection.Remo

teIpAddress?.ToString()!, _ =>

new FixedWindowRateLimiterOptions

{

PermitLimit = 10,

Window = TimeSpan.FromMinutes(1),

QueueLimit = 2

}));

});

app.UseRateLimiter();

✅ Helps protect APIs from abuse or DoS attacks.

Permalink & share

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

How to Enable Application Insights?

Answer:

Application Insights provides monitoring, telemetry, and tracing.

Setup:

builder.Services.AddApplicationInsightsTelemetry(builder.Configurati

on["APPINSIGHTS_INSTRUMENTATIONKEY"]);

Features:

  • Track requests, exceptions, and dependencies
  • Live metrics and dashboards
  • Custom events and telemetry
Permalink & share

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

How to Use Moq for Mocking Dependencies?

Answer:

Moq creates fake implementations of interfaces to control behavior during tests.

Example:

var mockRepo = new Mock<IProductRepository>();

mockRepo.Setup(x => x.GetAll()).Returns(new List<Product> { new

Product { Id = 1, Name = "Laptop" } });
var service = new ProductService(mockRepo.Object);
var products = service.GetAll();

Assert.Single(products);

✅ Use .Setup(), .Verify(), and .Returns() to simulate behavior.

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