Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Statelessness → Each request is independent; the server doesn’t store client state. Explain a bit more Client-Server Architecture → Separation of concerns between client UI and server logic. Uniform Interfa…
Short answer: uthorization: Bearer <token> Real-world example (ShopNest) ShopNest mobile app sends a JWT Bearer token. The API validates it and uses the user id from claims to load that user’s cart only. Say this i…
Short answer: Client sends token in Authorization header: Authorization: Bearer <token> Real-world example (ShopNest) ShopNest exposes REST APIs for cart and checkout. Controllers stay thin; business rules live in…
Short answer: REST → Lightweight, uses HTTP, usually JSON, easy to use, stateless. SOAP → Protocol-based, uses XML, more complex, built-in security & transactions. REST is more flexible and widely used for web and mo…
Short answer: Docker allows running ASP.NET Core apps in containers, portable across environments. Dockerfile Example: # Build stage FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app COPY *.csproj ./ RUN dotnet…
Short answer: Configuration providers are components that load configuration data from various sources. Explain a bit more Built-in Providers: JSON files (appsettings.json) Environment variables Command-line arguments In…
Short answer: public class LogActionFilter : ActionFilterAttribute public override void OnActionExecuting(ActionExecutingContext context) Console.WriteLine($"Action: {context.ActionDescriptor.DisplayName}"); Us…
Short answer: Hangfire or Quartz.NET for Background Jobs Hangfire Example code app.UseHangfireDashboard(); RecurringJob.AddOrUpdate(() => Console.WriteLine("Recurring job"), Cron.Daily); Quartz.NET: Supports…
Short answer: How to Test Minimal APIs? Answer: Minimal APIs are tested using WebApplicationFactory or TestServer. Example: var factory = new WebApplicationFactory<Program>(); Example code var client = factory.Crea…
Short answer: Stateless means the server does not store client session data. Each request must contain all the necessary information (like authentication tokens). This makes APIs scalable and reliable. Real-world example…
Short answer: Health Checking in ASP.NET Core builder.Services.AddHealthChecks() .AddSqlServer(connectionString) .AddCheck<CustomHealthCheck>("CustomCheck"); app.MapHealthChecks("/health"); Cust…
Short answer: 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…
Short answer: 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…
Short answer: Compiled queries improve performance by caching query translation. Example code private static readonly Func<AppDbContext, decimal, IEnumerable<Product>> _getExpensiveProducts = EF.CompileQuery(…
Short answer: Platform-independent (works across web, mobile, IoT). Simple, flexible, and scalable. Uses existing HTTP infrastructure. Lightweight (JSON/XML). Supports caching for better performance. Real-world example (…
Short answer: Rate Limiting Middleware in .NET 8 builder.Services.AddRateLimiter(options => { options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(httpContext => RateLimitPartition.GetFi…
Short answer: How to Enable Application Insights? Answer: Application Insights provides monitoring, telemetry, and tracing. Setup: builder.Services.AddApplicationInsightsTelemetry(builder.Configurati on["APPINSIGHTS…
Short answer: 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…
Short answer: Easier to learn & implement. Supports multiple formats (JSON, XML, plain text). Faster (less overhead). Works seamlessly with modern web & mobile apps. Better performance due to caching & statel…
Short answer: Suppose we have a User Service API: GET /users → Get all users GET /users/1 → Get user with ID=1 POST /users → Create a new user PUT /users/1 → Update user with ID=1 DELETE /users/1 → Delete user with ID=1…
Short answer: HATEOAS (Hypermedia As The Engine Of Application State) means responses contain links to related actions/resources. 👉 Example code { "id": 1, "name": "John", "links"…
Short answer: Common methods: API Keys → Simple tokens. Basic Auth → Username & password (not secure without HTTPS). OAuth 2.0 / OpenID Connect → Standard protocols for secure access. JWT (JSON Web Tokens) → Widely u…
Short answer: GET → Used to retrieve data, should not modify server state, and can be cached/bookmarked. POST → Used to create new resources or submit data. It modifies server state, is not idempotent, and cannot be cach…
Short answer: 200 OK → If the resource was successfully deleted and a response body is returned. 204 No Content → If the resource was deleted but no body is needed. 404 Not Found → If the resource does not exist. Real-wo…
Short answer: Safe → Because it only retrieves data without modifying server state. Idempotent → Multiple GET requests have the same result; no side effects occur. Real-world example (ShopNest) Creating an order is POST…
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Statelessness → Each request is independent; the server doesn’t store client state.
Client-Server Architecture → Separation of concerns between client UI and server logic. Uniform Interface → Standard HTTP methods and URIs. Cacheable → Responses can be cached to improve performance. Layered System → APIs can use intermediaries (like load balancers, proxies). Resource-based → Everything is treated as a resource (like users, orders, products).
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: uthorization: Bearer <token>
ShopNest mobile app sends a JWT Bearer token. The API validates it and uses the user id from claims to load that user’s cart only.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Client sends token in Authorization header: Authorization: Bearer <token>
ShopNest exposes REST APIs for cart and checkout. Controllers stay thin; business rules live in application services.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: REST → Lightweight, uses HTTP, usually JSON, easy to use, stateless. SOAP → Protocol-based, uses XML, more complex, built-in security & transactions. REST is more flexible and widely used for web and mobile apps.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: Docker allows running ASP.NET Core apps in containers, portable across environments. Dockerfile Example: # Build stage FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app COPY *.csproj ./ RUN dotnet restore COPY .
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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) builder.Configuration .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .AddCommandLine(args); Each provider plugs into the same configuration system, so you can access everything via IConfiguration. 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)
builder.Configuration .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .AddCommandLine(args); Each provider plugs into the same configuration system, so you can access everything via IConfiguration. 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. 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
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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?
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? 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? 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: 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: 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? 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: 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:
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: Hangfire or Quartz.NET for Background Jobs Hangfire
app.UseHangfireDashboard(); RecurringJob.AddOrUpdate(() => Console.WriteLine("Recurring job"), Cron.Daily); Quartz.NET: Supports cron-like scheduling and clustered execution.
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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);
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Stateless means the server does not store client session data. Each request must contain all the necessary information (like authentication tokens). This makes APIs scalable and reliable.
ShopNest exposes REST APIs for cart and checkout. Controllers stay thin; business rules live in application services.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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")); }
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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
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.
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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.
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: Compiled queries improve performance by caching query translation.
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. Pool Size=5; uthentication & Authorization
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Platform-independent (works across web, mobile, IoT). Simple, flexible, and scalable. Uses existing HTTP infrastructure. Lightweight (JSON/XML). Supports caching for better performance.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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…
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Core MVC ASP.NET Core MVC Tutorial · MVC
Short answer: 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.
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Easier to learn & implement. Supports multiple formats (JSON, XML, plain text). Faster (less overhead). Works seamlessly with modern web & mobile apps. Better performance due to caching & statelessness.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Suppose we have a User Service API: GET /users → Get all users GET /users/1 → Get user with ID=1 POST /users → Create a new user PUT /users/1 → Update user with ID=1 DELETE /users/1 → Delete user with ID=1 This shows how CRUD operations map directly to HTTP methods.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: HATEOAS (Hypermedia As The Engine Of Application State) means responses contain links to related actions/resources. 👉
{ "id": 1, "name": "John", "links": [ { "rel": "self", "href": "/users/1" }, { "rel": "orders", "href": "/users/1/orders" } } This helps clients navigate APIs dynamically.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Common methods: API Keys → Simple tokens. Basic Auth → Username & password (not secure without HTTPS). OAuth 2.0 / OpenID Connect → Standard protocols for secure access. JWT (JSON Web Tokens) → Widely used for stateless authentication.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: GET → Used to retrieve data, should not modify server state, and can be cached/bookmarked. POST → Used to create new resources or submit data. It modifies server state, is not idempotent, and cannot be cached.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: 200 OK → If the resource was successfully deleted and a response body is returned. 204 No Content → If the resource was deleted but no body is needed. 404 Not Found → If the resource does not exist.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Short answer: Safe → Because it only retrieves data without modifying server state. Idempotent → Multiple GET requests have the same result; no side effects occur.
Creating an order is POST /api/orders → 201 with Location header. Fetching is GET /api/orders/{id} → 200 or 404.