Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Use middleware for concerns that affect all requests (logging, CORS, authentication). Use filters for MVC-specific concerns tied to action execution (authorization, validation, caching). Filters can complem…
Short answer: API versioning enables multiple versions of your API to coexist, allowing clients to migrate gradually. Explain a bit more Common ways to version APIs in ASP.NET Core: URL versioning (e.g., /api/v1/products…
Short answer: api-version=1.0) Header versioning (custom header like api-version: 1.0) Media type versioning (via Accept header, e.g., application/json;v=1) Use the Microsoft.AspNetCore.Mvc.Versioning NuGet package: serv…
Short answer: Semantic versioning (semver) uses MAJOR.MINOR.PATCH format, e.g., 1.2.0. MAJOR version changes break backward compatibility. MINOR versions add functionality in a backward-compatible manner. PATCH versions…
Short answer: Mark old versions as deprecated via documentation and HTTP response headers. Return warning headers or custom fields indicating version deprecation. Gradually phase out old versions, allowing clients to mig…
Short answer: CORS (Cross-Origin Resource Sharing) is a browser security feature that restricts web pages from making requests to a different domain than the one that served the web page, to prevent cross-site attacks. C…
Short answer: pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpec…
Short answer: Configure in Startup.cs or Program.cs: services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", builder => { builder.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); });…
Short answer: For certain CORS requests (e.g., methods other than GET/POST or custom headers), browsers send an OPTIONS request first, called a preflight. The server must respond with allowed methods, headers, and origin…
Short answer: Global CORS: Apply a policy for all endpoints by adding middleware early in the pipeline with app.UseCors(...). Per-endpoint CORS: Apply CORS policies selectively using the [EnableCors("PolicyName"…
Short answer: To allow cookies or credentials in cross-origin requests, configure: builder.WithOrigins(" .AllowCredentials() .AllowAnyHeader() .AllowAnyMethod(); Clients must send requests with credentials: 'include…
Short answer: Improperly configured CORS can expose your API to CSRF and data theft. Avoid using AllowAnyOrigin with AllowCredentials as browsers block it. Restrict origins to trusted domains. Validate CORS headers and a…
Short answer: Kestrel is the default cross-platform web server for ASP.NET Core, lightweight and fast. IIS acts as a reverse proxy on Windows, forwarding requests to Kestrel. Reverse proxies improve security, manage SSL,…
Short answer: InProcess hosting runs ASP.NET Core app inside the IIS worker process (w3wp.exe), better performance. OutOfProcess hosting runs the app in a separate process, IIS proxies requests to it. InProcess is defaul…
Short answer: Health checks provide endpoints to report app health. Use Microsoft.AspNetCore.Diagnostics.HealthChecks. Configure checks for databases, external services, dependencies. Useful for Kubernetes, load balancer…
Short answer: ASP.NET Core has built-in logging with providers (Console, Debug, EventSource). Third-party libs like Serilog and NLog offer rich sinks, structured logging. Configure logging via appsettings.json or code. R…
Short answer: compression In-memory caching stores data on server memory for fast retrieval. Distributed caching uses external stores (Redis, SQL) for multiple servers. Response compression reduces payload size using gzi…
Short answer: Avoid blocking calls in async code to prevent deadlocks. Use async/await properly. Protect shared data with locks or concurrent collections. Avoid thread starvation with thread pool tuning. Real-world examp…
Short answer: Memory leaks can occur if IDisposable objects aren’t disposed. Use dependency injection lifetimes properly. Be cautious with static references and events holding objects. Use tools like dotMemory, PerfView.…
Short answer: Design apps to be stateless so any server instance can handle requests. Use distributed caches or external session stores. Load balancers distribute traffic to multiple instances. Real-world example (ShopNe…
Short answer: Containerize apps with Docker for consistent deployments. Use Azure App Services, Azure Kubernetes Service for cloud hosting. Set up CI/CD pipelines (GitHub Actions, Azure DevOps) for automated builds and d…
Short answer: Monitor app health, request metrics, errors. Use OpenTelemetry for distributed tracing. Integrate with Application Insights, Prometheus, Grafana. Real-world example (ShopNest) A ShopNest checkout request fl…
Short answer: Enforce HTTPS. Use Anti-forgery tokens to prevent CSRF. Sanitize input to prevent XSS. Follow OWASP guidelines to secure apps. Real-world example (ShopNest) A ShopNest checkout request flows through middlew…
Short answer: Use Response Compression Middleware to compress responses. Use Response Caching Middleware to cache GET responses. Middleware can be composed for layered processing. Real-world example (ShopNest) ShopNest p…
Short answer: Response caching caches HTTP responses based on headers. Output caching (new in ASP.NET Core 7) caches entire output of endpoints. Real-world example (ShopNest) A ShopNest checkout request flows through mid…
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Use middleware for concerns that affect all requests (logging, CORS, authentication). Use filters for MVC-specific concerns tied to action execution (authorization, validation, caching). Filters can complement middleware for granular control within MVC. Example: Use middleware for global exception logging, filters for handling MVC-specific exceptions and returning appropriate views or API responses. Versioning, CORS
ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: API versioning enables multiple versions of your API to coexist, allowing clients to migrate gradually.
Common ways to version APIs in ASP.NET Core: URL versioning (e.g., /api/v1/products) Query string versioning (e.g., /api/products?api-version=1.0) Header versioning (custom header like api-version: 1.0) ● Media type versioning (via Accept header, e.g., application/json;v=1) Use the Microsoft.AspNetCore.Mvc.Versioning NuGet package: services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
options.ReportApiVersions = true; });
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: api-version=1.0) Header versioning (custom header like api-version: 1.0) Media type versioning (via Accept header, e.g., application/json;v=1) Use the Microsoft.AspNetCore.Mvc.Versioning NuGet package: services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0);……… api-version=1.
0) Header versioning (custom header like api-version: 1.0) Media type versioning (via Accept header, e.g., application/json;v=1) Use the Microsoft.AspNetCore.Mvc.Versioning NuGet package: services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); options.ReportApiVersions = true; }); api-version=1.0) Header versioning (custom header like api-version: 1.0) Media type versioning (via Accept header, e.g., application/json;v=1) Use the Microsoft.AspNetCore.Mvc.Versioning NuGet package: services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new…
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Semantic versioning (semver) uses MAJOR.MINOR.PATCH format, e.g., 1.2.0. MAJOR version changes break backward compatibility. MINOR versions add functionality in a backward-compatible manner. PATCH versions are for backward-compatible bug fixes. Version negotiation allows clients and servers to agree on an API version via headers or URL. Servers should support multiple versions and respond with supported version info.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Mark old versions as deprecated via documentation and HTTP response headers. Return warning headers or custom fields indicating version deprecation. Gradually phase out old versions, allowing clients to migrate. Consider introducing sunset policies and endpoints to notify clients.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: CORS (Cross-Origin Resource Sharing) is a browser security feature that restricts web pages from making requests to a different domain than the one that served the web page, to prevent cross-site attacks. CORS defines a way for servers to allow controlled access to resources from a different origin.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin"); pp.UseCors("AllowSpecificOrigin");
ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Configure in Startup.cs or Program.cs: services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", builder => { builder.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); Enable middleware: app.UseCors("AllowSpecificOrigin");
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: For certain CORS requests (e.g., methods other than GET/POST or custom headers), browsers send an OPTIONS request first, called a preflight. The server must respond with allowed methods, headers, and origins. Properly configured CORS policies handle preflight requests automatically.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Global CORS: Apply a policy for all endpoints by adding middleware early in the pipeline with app.UseCors(...). Per-endpoint CORS: Apply CORS policies selectively using the [EnableCors("PolicyName")] or [DisableCors] attributes on controllers or actions.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: To allow cookies or credentials in cross-origin requests, configure: builder.WithOrigins(" .AllowCredentials() .AllowAnyHeader() .AllowAnyMethod(); Clients must send requests with credentials: 'include'. Note: Allowing credentials disables the wildcard (*) origin.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Improperly configured CORS can expose your API to CSRF and data theft. Avoid using AllowAnyOrigin with AllowCredentials as browsers block it. Restrict origins to trusted domains. Validate CORS headers and avoid overly permissive policies. Use HTTPS to secure cross-origin requests. Cross‑Cutting / Advanced / “Miscellaneous”
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Kestrel is the default cross-platform web server for ASP.NET Core, lightweight and fast. IIS acts as a reverse proxy on Windows, forwarding requests to Kestrel. Reverse proxies improve security, manage SSL, handle load balancing. On Linux, Nginx or Apache often act as reverse proxies to Kestrel.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: InProcess hosting runs ASP.NET Core app inside the IIS worker process (w3wp.exe), better performance. OutOfProcess hosting runs the app in a separate process, IIS proxies requests to it. InProcess is default in ASP.NET Core 3.0+ for IIS hosting.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Health checks provide endpoints to report app health. Use Microsoft.AspNetCore.Diagnostics.HealthChecks. Configure checks for databases, external services, dependencies. Useful for Kubernetes, load balancers.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: ASP.NET Core has built-in logging with providers (Console, Debug, EventSource). Third-party libs like Serilog and NLog offer rich sinks, structured logging. Configure logging via appsettings.json or code.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: compression In-memory caching stores data on server memory for fast retrieval. Distributed caching uses external stores (Redis, SQL) for multiple servers. Response compression reduces payload size using gzip, Brotli middleware.
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Avoid blocking calls in async code to prevent deadlocks. Use async/await properly. Protect shared data with locks or concurrent collections. Avoid thread starvation with thread pool tuning.
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Memory leaks can occur if IDisposable objects aren’t disposed. Use dependency injection lifetimes properly. Be cautious with static references and events holding objects. Use tools like dotMemory, PerfView.
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Design apps to be stateless so any server instance can handle requests. Use distributed caches or external session stores. Load balancers distribute traffic to multiple instances.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Containerize apps with Docker for consistent deployments. Use Azure App Services, Azure Kubernetes Service for cloud hosting. Set up CI/CD pipelines (GitHub Actions, Azure DevOps) for automated builds and deployments.
ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Monitor app health, request metrics, errors. Use OpenTelemetry for distributed tracing. Integrate with Application Insights, Prometheus, Grafana.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Enforce HTTPS. Use Anti-forgery tokens to prevent CSRF. Sanitize input to prevent XSS. Follow OWASP guidelines to secure apps.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Use Response Compression Middleware to compress responses. Use Response Caching Middleware to cache GET responses. Middleware can be composed for layered processing.
ShopNest pipeline order matters: exception handling → HTTPS → auth → authorization → endpoints. Auth must run before protected APIs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Response caching caches HTTP responses based on headers. Output caching (new in ASP.NET Core 7) caches entire output of endpoints.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.