Saturday, August 30, 2025

.Net InterView Questions And Answers 2025 for Experience

 




  select Count(Productid) as PrCount from products

  group by ProducId

  Having(PrCount)> 10

  OpenID

  1. Throttling in web API

Throttling in a Web API means controlling the number of requests a client/user can make within a specific time window. It’s mainly used to protect the API from abuse, ensure fair usage among clients, and maintain performance under heavy load.

Why Throttling is Needed

  • Prevent abuse / DoS attacks – stops a single client from overwhelming the server.

  • Fair usage – ensures all clients get equal access.

  • Performance stability – prevents spikes from crashing the API.

  • Cost control – especially for cloud-hosted APIs (Azure, AWS) where usage costs matter.


2.What is Versioning in web API?

Versioning in Web API is the practice of managing changes to your API without breaking existing clients. Since APIs evolve over time (new features, deprecations, contract changes), versioning ensures backward compatibility while still allowing improvements.

Why API Versioning?

  • Clients using old versions don’t break when API changes.

  • Supports gradual migration to newer versions.

  • Allows experimentation and safe deprecation of old endpoints.

load balaning in web api traffic

private constructor

ModelBinder

Agile Methodoligies

Dockers

MessageBrokers

oops

ioc

DI

olap and Dynamics

versions

Functions and Methods in C# 


Micro services

Design Patterns

 Azure Interview Questions And Answers 

What are the differences between Saas, PaaS, and IaaS Cloud Services?

SaaS: Software as a Service 

Using their Software Application and orgnization paying for that.

PaaS : Platform a

AZure APPS

Azure Pass

Azure Cloud

Azure Bus

Azure Key Vault

JWT Tokens

javascript vs Jquery 

improving message bus queue    

Referral Questions:


 


Topic


Question


.NET Core


What is the difference between .NET Core and .NET Framework?


.NET Core


Explain the purpose of the IServiceProvider interface in .NET Core Dependency Injection.


.NET Core


How does middleware work in .NET Core, and how can you create custom middleware?


.NET Core


What is the use of IHostedService in .NET Core applications?


.NET Core


How do you implement configuration management in a .NET Core application?


.NET Core


What are the differences between IApplicationBuilder and IWebHostBuilder?


.NET Core


Explain the difference between a self-contained deployment and a framework-dependent deployment in .NET Core.


.NET Core


How can you handle logging in .NET Core using the built-in logging framework?


.NET Core


What are the benefits of using the Kestrel web server in .NET Core?


.NET Core


How do you implement Health Checks in a .NET Core application?


C#


What are the main differences between abstract classes and interfaces in C#?


C#


What is the purpose of the using statement, and how does it work with the IDisposable interface?


C#


Explain the difference between value types and reference types in C#.


C#


What is the difference between Task and Thread in C#?


C#


How do you implement exception handling using try-catch-finally in C#?


C#


Explain the concept of async and await in C#.


C#


What are the differences between readonly, const, and static keywords in C#?


C#


How does yield work in C#? Provide an example.


C#


What is the difference between String and StringBuilder in C#?


C#


How do extension methods work in C#, and how are they implemented?


OOPS


What are the four principles of Object-Oriented Programming (OOP)? Explain each.


OOPS


How does polymorphism work in C#, and what are its types?


OOPS


What is encapsulation, and how is it implemented in C#?


OOPS


Explain the concept of inheritance and its types with examples.


OOPS


What is the difference between method overloading and method overriding?


OOPS


How do constructors and destructors work in C#?


OOPS


What is the difference between an abstract class and a concrete class?


OOPS


Explain the concept of interfaces in OOP. How are they different from abstract classes?


OOPS


What is the purpose of design patterns in OOP, and can you give an example of one?


OOPS


What is the concept of dependency inversion in OOP?


ASP.NET Core API


How do you create a RESTful API in ASP.NET Core?


ASP.NET Core API


What is the purpose of the Startup class in an ASP.NET Core application?


ASP.NET Core API


How do you handle authentication and authorization in ASP.NET Core API?


ASP.NET Core API


Explain the difference between AddControllers and AddControllersWithViews.


ASP.NET Core API


How do you version APIs in ASP.NET Core?


ASP.NET Core API


What are the benefits of using attribute routing in ASP.NET Core?


ASP.NET Core API


How do you handle model validation in ASP.NET Core Web APIs?


ASP.NET Core API


What is the purpose of the ActionResult<T> return type in ASP.NET Core?


ASP.NET Core API


How can you implement Swagger for API documentation in ASP.NET Core?


ASP.NET Core API


How do you enable and use CORS in an ASP.NET Core API?


Angular


What are the key differences between Angular and AngularJS?


Angular


What is the purpose of NgModules in Angular?


Angular


How do you implement two-way data binding in Angular?


Angular


Explain the difference between services and directives in Angular.


Angular


What is lazy loading in Angular, and how is it implemented?


Angular


How do you handle state management in Angular applications?


Angular


What are Angular lifecycle hooks, and how are they used?


Angular


What is the difference between observable and promise in Angular?


Angular


How do you secure an Angular application?


Angular


How do you implement dependency injection in Angular?


SQL Server


What is the difference between a clustered and a non-clustered index in SQL Server?


SQL Server


How do you implement transactions in SQL Server, and what is their purpose?


SQL Server


Explain the differences between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.


SQL Server


What are stored procedures, and how are they different from functions?


SQL Server


How do you optimize SQL queries for better performance?


SQL Server


What are the differences between primary keys and foreign keys?


SQL Server


Explain the purpose of normalization and denormalization in database design.


SQL Server


How do you use CTE (Common Table Expressions) in SQL Server?


SQL Server


What is the purpose of the SQL Server Profiler, and how is it used?


SQL Server


What are indexes in SQL Server, and how do you maintain them?


Event Driven Archictechture

Azure Databus performance Improvement

Azure Fabrics

Azure highly available Database

Azure database

Azure Datafactory

  

How to Implement MicroServices in .Net Core Application- Point-to-point to explanation

 

1) Service boundaries & contracts

  • One business capability per service (e.g., Orders, Payments, Catalog). Each owns its own database.
  • API surface: REST (JSON) or gRPC for synchronous calls; events (Kafka/RabbitMQ/Azure Service Bus) for async integration.
  • Version your APIs (e.g., /v1), keep backward compatible changes, use OpenAPI/Swagger and contract tests (Pact).

2) Resilience patterns (timeouts, retries, circuit breaker, bulkhead)

Use HttpClientFactory + Polly on every outbound call:

builder.Services.AddHttpClient("CatalogClient", c =>

{

    c.BaseAddress = new Uri(config["CatalogUrl"]);

    c.Timeout = TimeSpan.FromSeconds(3);

})

.AddTransientHttpErrorPolicy(p => p.WaitAndRetryAsync(

    retryCount: 3,

    sleepDurationProvider: attempt => TimeSpan.FromMilliseconds(200 * Math.Pow(2, attempt)), // expo backoff

    onRetry: (outcome, ts, attempt, ctx) =>

        logger.LogWarning(outcome.Exception, "Retry {Attempt}", attempt)))

.AddTransientHttpErrorPolicy(p => p.CircuitBreakerAsync(

    handledEventsAllowedBeforeBreaking: 5,

    durationOfBreak: TimeSpan.FromSeconds(30)))

.AddPolicyHandler(Policy.BulkheadAsync<HttpResponseMessage>(maxParallelization: 50, maxQueuingActions: 100));

Rules of thumb

  • Always set timeouts on I/O.
  • Prefer idempotent operations; send Idempotency-Key headers for POSTs where possible.
  • Use cancellation tokens end-to-end.

3) Circuit breaker semantics

  • Trip when a dependency is unhealthy; fail fast and return a cached/partial response or friendly error.
  • Expose breaker state via metrics and health checks (see §5).

4) Data & database handling (consistency without distributed transactions)

  • Database per service (EF Core or Dapper). No cross-service joins.
  • Propagate data between services using domain events—not shared tables.
  • Ensure atomicity with the Outbox pattern:
    1. Write your entity and an OutboxMessage row in the same DB transaction.
    2. A background Outbox Publisher reads unpublished rows and emits them to the broker, then marks them sent.

// Inside your OrderService command handler

await using var tx = db.Database.BeginTransactionAsync();

db.Orders.Add(order);

db.Outbox.Add(new OutboxMessage {

    Type = "OrderPlaced",

    Payload = JsonSerializer.Serialize(new { order.Id, order.Total, order.CustomerId }),

    OccurredOn = DateTimeOffset.UtcNow

});

await db.SaveChangesAsync();

await tx.CommitAsync();

// BackgroundService publisher

protected override async Task ExecuteAsync(CancellationToken ct)

{

    while (!ct.IsCancellationRequested)

    {

        var messages = await db.Outbox

            .Where(m => m.SentOn == null)

            .OrderBy(m => m.OccurredOn)

            .Take(100).ToListAsync(ct);

 

        foreach (var msg in messages)

        {

            await broker.PublishAsync(msg.Type, msg.Payload, ct);

            msg.SentOn = DateTimeOffset.UtcNow;

        }

        await db.SaveChangesAsync(ct);

        await Task.Delay(TimeSpan.FromSeconds(1), ct);

    }

}

  • Updating “relative/related” databases: consume those events in other services to update local read models (CQRS). Use Sagas (orchestration or choreography) for multi-step processes (e.g., Order → Reserve Inventory → Process Payment → Arrange Shipping), with timeouts + compensation.

5) Health checks, readiness, and monitoring

Add liveness (process alive) and readiness (deps OK) endpoints:

builder.Services.AddHealthChecks()

    .AddSqlServer(config.GetConnectionString("OrdersDb"))

    .AddRabbitMQ(config["RabbitMq:Connection"])

    .AddUrlGroup(new Uri(config["CatalogUrl"] + "/health"), name: "catalog");

 

app.MapHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false });

app.MapHealthChecks("/health/ready", new HealthCheckOptions {

    Predicate = _ => true,

    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse

});

  • Kubernetes/Containers probe /health/live and gate traffic on /health/ready.
  • Add self-diagnostics (thread pool starvation, GC info) via EventCounters exported by OpenTelemetry.

6) Observability (logs, traces, metrics)

Unified, structured telemetry makes bugs easy to fix.

OpenTelemetry (logs + traces + metrics) → backends like Grafana Tempo/Prometheus/Loki, Jaeger, Elastic, or Azure Application Insights.

builder.Services.AddOpenTelemetry()

 .WithTracing(t => t

     .AddAspNetCoreInstrumentation()

     .AddHttpClientInstrumentation()

     .AddSqlClientInstrumentation()

     .AddSource("OrderService")

     .AddOtlpExporter()) // or Azure Monitor exporter

 .WithMetrics(m => m

     .AddAspNetCoreInstrumentation()

     .AddRuntimeInstrumentation()

     .AddHttpClientInstrumentation()

     .AddPrometheusExporter());

 

app.MapPrometheusScrapingEndpoint(); // /metrics

Structured logging (e.g., Serilog → console/JSON + sink of choice):

Log.Logger = new LoggerConfiguration()

    .Enrich.FromLogContext()

    .Enrich.WithCorrelationId()

    .WriteTo.Console(new JsonFormatter())

    .WriteTo.Seq(config["SeqUrl"]) // or Elastic/Azure

    .CreateLogger();

 

builder.Host.UseSerilog();

  • Include CorrelationId/TraceId in every log; propagate with middleware:

app.Use(async (ctx, next) =>

{

    var cid = ctx.Request.Headers["X-Correlation-ID"].FirstOrDefault() ?? Guid.NewGuid().ToString();

    ctx.Items["CorrelationId"] = cid;

    ctx.Response.Headers["X-Correlation-ID"] = cid;

    using (LogContext.PushProperty("CorrelationId", cid))

        await next();

});

  • Emit domain events and key business metrics (orders placed, failures, latencies, queue depth).

7) API gateway / proxy servers

  • Use a Gateway for routing, TLS, auth/ratelimiting, request shaping:
    • YARP (in-process .NET reverse proxy) or Ocelot; at the edge you can also use NGINX/Envoy.
  • Centralize AuthN/Z (OAuth2/OIDC via Azure AD, Auth0, or Duende IdentityServer), rate limits, request/response size limits, CORS, and header normalization at the gateway.
  • Prefer service discovery (K8s DNS) and mTLS in cluster; consider a service mesh (Istio/Linkerd) for uniform retries/mtls/traffic shifting and better telemetry without code changes.

8) Security & configuration

  • Never share DBs across services. Grant least privilege per service.
  • Secrets via Azure Key Vault / K8s secrets; bind with IOptions<T> and validate on startup.
  • Enforce TLS everywhere, JWT validation, rotating keys, and input validation (FluentValidation).

9) Deployment & runtime

  • Containerize each service (Docker), build once, promote the same image through Dev → QA → Prod.
  • Orchestrate with Kubernetes (AKS) or Azure App Services for simpler cases.
  • Blue/Green or Canary deployments; mesh/gateway can split traffic gradually.
  • Horizontal scaling via HPA (CPU/RPS/latency). Keep services stateless; externalize state (DB/cache).
  • Caching: local memory for tiny TTLs, Redis for shared cache; always set cache keys + expirations.

10) CI/CD and quality gates

  • GitHub Actions / Azure DevOps Pipelines:
    • Build → unit/integration/contract tests → SCA & SAST → container scan → publish image → deploy via Helm/Bicep/Terraform.
    • Block merges without green tests and security checks.
  • Spin ephemeral test environments per PR when feasible.

11) Diagnostics & “easy bug fixing”

  • Global exception handler → consistent error envelopes with traceId:

app.UseExceptionHandler(builder =>

{

    builder.Run(async ctx =>

    {

        var traceId = Activity.Current?.Id ?? ctx.TraceIdentifier;

        var problem = new { traceId, message = "Unexpected error." };

        ctx.Response.StatusCode = 500;

        await ctx.Response.WriteAsJsonAsync(problem);

    });

});

  • Feature flags (Azure App Configuration) for safe rollouts; dark-launch code paths.
  • Replayable messages (don’t auto-ack until processed). Keep dead-letter queues and dashboards.
  • Synthetic checks (probes that place a tiny test order in lower envs and alert on end-to-end failure).

12) Database migrations & uptime

  • Apply EF Core migrations at startup (carefully) or via migration jobs;
    • Prefer expand-and-contract: add new columns/tables (expand), release code that writes both, backfill, then remove old fields (contract).
  • For read models, permit rebuild from event streams or upstream APIs if corrupted.

13) Monitoring & alerts you’ll actually use

  • Golden signals per service: Latency, Traffic, Errors, Saturation.
  • Alert on SLIs/SLOs (e.g., p95 < 300ms, error rate < 1%), queue lag, breaker open rate, DB CPU, connection pool exhaustion.
  • Route alerts to Teams/Slack with runbooks linked (how to diagnose/rollback).

14) Local/dev ergonomics

  • Docker-compose for local broker + DB + dependencies.
  • Seed data + test fixtures; make services start with sensible defaults.
  • Makefile/PS scripts for common tasks; one-command bootstrap.

Minimal reference architecture (quick checklist)

  • ASP.NET Core services (+ gRPC if needed)
  • HttpClientFactory + Polly (timeouts/retries/circuit breaker/bulkhead)
  • Outbox + BackgroundPublisher; events over Kafka/RabbitMQ/Azure Service Bus
  • DB per service (EF Core/Dapper) + migrations (expand/contract)
  • OpenTelemetry (traces/metrics/logs) → Prometheus/Grafana/Tempo or App Insights
  • Serilog structured logging + correlation IDs
  • Health checks: /health/live, /health/ready
  • API Gateway: YARP/Ocelot; edge NGINX/Envoy; OAuth2/OIDC
  • Containerized; AKS/App Service; blue/green or canary
  • CI/CD with tests, scans, infrastructure as code
  • Feature flags; DLQs; synthetic probes; runbooks


 

Amazon.in


Don't Copy

Protected by Copyscape Online Plagiarism Checker

Pages

Offers