Technical interview questions with detailed answers—organized by course, like Dot Net Tutorials interview sections. Original content for Toolliyo Academy.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
A REST (Representational State Transfer) API is an architectural style for designing
networked applications. It uses HTTP methods (GET, POST, PUT, DELETE) to perform
operations on resources identified by URLs (endpoints). Data is usually exchanged in JSON
or XML format.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
exceptions.
Example in ASP.NET Core:
app.UseExceptionHandler(appError =>
appError.Run(async context =>
context.Response.StatusCode = 500; // Internal Server Error
context.Response.ContentType = "application/json";
var contextFeature =
context.Features.Get<IExceptionHandlerFeature>();
if(contextFeature != null)
// Log exception (use ILogger)
await context.Response.WriteAsync(new
StatusCode = context.Response.StatusCode,
Message = "Internal Server Error.",
Detail = contextFeature.Error.Message
}.ToString());
});
});
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Review the concept and prepare a concise verbal explanation with a real project example.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
logic.
products).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Example:
"status": 400,
"error": "Bad Request",
"details": "Email is required"
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Review the concept and prepare a concise verbal explanation with a real project example.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Example in ASP.NET Core:
var user = dbContext.Users.Find(id);
if (user == null)
return NotFound(new { status = 404, error = "User not found" });
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Client sends token in Authorization header:
Authorization: Bearer <token>
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
HTTP provides the transport mechanism and defines methods:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Example:
public class UserModel
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Invalid email format")]
public string Email { get; set; }
[Required]
[MinLength(6, ErrorMessage = "Password must be at least 6
characters")]
public string Password { get; set; }
// Controller action
[HttpPost("register")]
public IActionResult Register([FromBody] UserModel model)
if (!ModelState.IsValid)
var errors = ModelState.Values.SelectMany(v =>
v.Errors).Select(e => e.ErrorMessage);
return BadRequest(new { status = 400, error = "Validation
Failed", details = errors });
return Ok("User registered successfully");
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Example using ILogger in ASP.NET Core:
private readonly ILogger<MyController> _logger;
public MyController(ILogger<MyController> logger)
_logger = logger;
[HttpGet("{id}")]
public IActionResult GetUser(int id)
_logger.LogInformation("Fetching user with id {UserId}", id);
try
var user = dbContext.Users.Find(id);
if (user == null)
_logger.LogWarning("User with id {UserId} not found",
id);
return NotFound();
return Ok(user);
catch (Exception ex)
_logger.LogError(ex, "Error fetching user with id {UserId}",
id);
return StatusCode(500, "Internal Server Error");
This covers all core aspects of error handling and debugging for REST APIs.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Review the concept and prepare a concise verbal explanation with a real project example.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
An endpoint is a specific URL that represents a resource in a REST API.
👉 Example:
→ Represents user with ID 1.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
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.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Review the concept and prepare a concise verbal explanation with a real project example.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Suppose we have a User Service API:
This shows how CRUD operations map directly to HTTP methods.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
In REST, everything is modeled as a resource (users, products, orders). Each resource is
identified by a URI and can be manipulated using standard HTTP methods.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
HATEOAS (Hypermedia As The Engine Of Application State) means responses contain
links to related actions/resources.
👉 Example:
"id": 1,
"name": "John",
"links": [
{ "rel": "self", "href": "/users/1" },
{ "rel": "orders", "href": "/users/1/orders" }
This helps clients navigate APIs dynamically.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Common methods:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Middleware is software that sits between client requests and server responses.
Used for:
🔹 HTTP Methods & Verbs – REST API Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
cached/bookmarked.
not idempotent, and cannot be cached.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Yes. If the resource does not exist, PUT can create it at the specified URI. Example:
👉 PUT /users/100 → If user 100 doesn’t exist, it will be created.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Idempotency means multiple identical requests have the same effect as one.
change.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example:
email.
not included.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
The GET method is used to fetch data because it is safe, idempotent, and optimized for
retrieval operations.
🔹 HTTP Status Codes – REST API Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
HTTP status codes are 3-digit numbers returned by the server to indicate the result of a
client request.
They are important because they:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It indicates the request was successful, and the server is returning the expected response
body (e.g., GET request returning data).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It indicates that a new resource was successfully created. Usually returned after a POST
request, along with a Location header pointing to the new resource.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Returned when the request is malformed or invalid, such as:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It means the client is not authenticated (missing/invalid credentials). The request cannot
proceed without proper authentication (e.g., missing token).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
endpoint).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It indicates a server-side failure (unexpected error, crash, or unhandled exception). It’s a
generic error and should be logged for debugging.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It means the client is authenticated but not authorized to access the resource.
👉 Example: A normal user trying to access an admin-only endpoint.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It indicates the request was well-formed (valid syntax) but could not be processed due to
semantic errors.
👉 Example: Submitting a form where email is valid format but already exists.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It means the resource has not changed since the last request. Commonly used with
caching to improve performance (client uses cached version).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It indicates the server timed out waiting for the client’s request.
👉 Example: Client took too long to send data in a POST request.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
503 indicates the server is temporarily unavailable (e.g., maintenance, overload).
Best practices:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
A redirect tells the client to fetch a resource from a different URL.
bookmarks/links).
🔹 REST Principles & Architecture – Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Statelessness means each client request to the server must contain all the necessary
information to process it (like authentication token, parameters, body). The server does not
store client session state.
👉 Example in ASP.NET Core Web API:
[HttpGet("profile")]
public IActionResult GetProfile([FromHeader] string token)
if (string.IsNullOrEmpty(token)) return Unauthorized();
// Token is validated each time (stateless, no session memory)
return Ok(new { Name = "John Doe", Email = "john@example.com"
});
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
It means REST APIs separate the client (frontend/UI) and server (backend logic,
database).
This separation improves scalability and flexibility.
👉 Example:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Responses from the server should indicate whether they are cacheable or not, to improve
performance and scalability. Clients and intermediaries can reuse cached responses.
👉 Example in ASP.NET Core:
[HttpGet("products")]
[ResponseCache(Duration = 60)] // Cache for 60 seconds
public IActionResult GetProducts()
return Ok(new[] { "Laptop", "Mouse", "Keyboard" });
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
The uniform interface ensures that REST APIs follow consistent conventions for
communication, making them predictable and easy to use.
Key aspects:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
In REST, resources (like users, products, orders) are identified with URLs instead of
actions.
👉 Example in ASP.NET Core Web API:
// Instead of action-based
GET /getUser?id=1
// Use resource-based
GET /users/1
This makes APIs cleaner and more intuitive.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
horizontally.
API.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Each request and response should have enough metadata (headers, content type, status
codes) to describe how to process it, without external context.
👉 Example in ASP.NET Core:
return Ok(new
Id = 1,
Name = "John",
Links = new[] { new { Rel = "self", Href = "/users/1" } }
});
Here, the response describes itself (content type = JSON, includes resource links).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Discoverability means clients can navigate and learn available actions through metadata
or hypermedia links, without hardcoding routes.
👉 Example using HATEOAS in ASP.NET Core Web API:
[HttpGet("users/{id}")]
public IActionResult GetUser(int id)
var user = new { Id = id, Name = "Alice" };
var response = new
user,
links = new[]
new { rel = "self", href = Url.Action("GetUser", new {
id }) },
new { rel = "orders", href = Url.Action("GetUserOrders",
new { id }) }
return Ok(response);
The API response itself guides the client to related resources (user’s orders, profile, etc.).
🔹 API Design Best Practices – REST API Interview
Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
(/getUserOrders).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Versioning ensures backward compatibility when APIs change.
Common approaches:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Return proper status codes and a structured error object:
👉 Example in ASP.NET Core:
"status": 400,
"error": "Invalid Request",
"details": "Email field is required"
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example: GET /users?page=2&limit=20.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
An API key is a unique token used to authenticate requests.
👉 Example:
GET /users?apikey=12345
Best practice: Send in headers → Authorization: ApiKey 12345.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Pros:
Cons:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example in EF Core:
var user = db.Users.FirstOrDefault(u => u.Email == email);
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
later (via polling, callbacks, or webhooks).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Webhooks are server-to-server callbacks triggered by events.
👉 Example: Stripe API calls your endpoint /payment/confirmed when a payment
succeeds.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example Response:
Allow: GET, POST, PUT, DELETE
Access-Control-Allow-Origin: *
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
🔹 Advanced REST API Design – Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Tools: Swagger (OpenAPI), Postman, Redoc.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
(Node.js), xUnit/NUnit (C#).
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example: File processing, report generation.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
monitoring.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example in ASP.NET Core:
services.AddCors(options =>
options.AddPolicy("MyPolicy",
builder => builder.WithOrigins("
.AllowAnyHeader()
.AllowAnyMethod());
});
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example: 100 requests/minute per API key.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
"status": 400,
"error": "Invalid Data",
"details": "Email is required"
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Review the concept and prepare a concise verbal explanation with a real project example.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
SDKs.
🔹 API Scalability & Performance – Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
Caching is storing frequently used data temporarily to reduce server load and improve
response time.
Implementation methods:
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
issues.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
👉 Example in ASP.NET Core: Add XML formatter with
services.AddControllers()
.AddXmlSerializerFormatters();
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
users.
👉 Example: Cloudflare, Akamai, AWS CloudFront.
🔹 API Documentation & Tools – Interview Q&A
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
security details.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
controllers and annotations.
services.AddSwaggerGen(c =>
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version =
"v1" });
});
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
"My API v1"));
also support annotations and automatic documentation.
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
ASP.NET Web API ASP.NET Core Web API Tutorial · REST API
🔹 Error Handling & Debugging – Interview Q&A