ASP.NET Core Interview

Routing, Controllers & Model Binding

ASP.NET Core interview questions covering routing, controllers & model binding.

25 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

25 Results
101
Mid-LevelIntermediate

What is routing in ASP.NET Core?

Routing is the mechanism that matches an incoming HTTP request to an application endpoint and can also generate URLs for endpoints.

102
Mid-LevelIntermediate

What is conventional routing in ASP.NET Core MVC?

Conventional routing defines route patterns centrally, usually in Program.cs. The pattern is applied across controllers and actions according to naming conventions.

103
Mid-LevelIntermediate

What is attribute routing?

Attribute routing defines routes directly on controllers and actions using attributes such as Route, HttpGet, HttpPost, HttpPut, and HttpDelete.

104
Mid-LevelIntermediate

What is the difference between conventional routing and attribute routing?

Conventional routing defines general route templates in one central location and relies on controller/action conventions. Attribute routing places route templates directly on controllers and actions.

105
Mid-LevelIntermediate

What are route parameters?

Route parameters are variable segments in a route template. Their values are extracted from the URL and made available to model binding.

106
Mid-LevelIntermediate

What are route constraints?

Route constraints restrict which URL values can match a route parameter. Built-in constraints include int, guid, bool, datetime, length, min, max, and others.

107
Mid-LevelIntermediate

What are optional route parameters and default route values?

An optional route parameter is marked with a question mark, such as {id?}. The route can match whether or not that segment is present.

108
Mid-LevelIntermediate

What is a controller in ASP.NET Core MVC?

A controller is a class that participates in handling HTTP requests in the MVC pattern. It receives input, coordinates application services, and returns an action result.

109
Mid-LevelIntermediate

What is the difference between Controller and ControllerBase?

ControllerBase provides the core functionality needed for HTTP endpoints, including model state, status-code helpers, request information, and action result helpers. It is commonly used for APIs.

110
Mid-LevelIntermediate

What is an action method?

An action method is a public controller method that can be selected by routing to handle an HTTP request.

111
Mid-LevelIntermediate

What is IActionResult?

IActionResult is an abstraction representing the result of an MVC action. Different implementations can produce views, redirects, JSON responses, files, status codes, or other HTTP responses.

112
Mid-LevelIntermediate

What are common ActionResult types in ASP.NET Core MVC?

Common MVC results include ViewResult for rendering a view, RedirectResult and RedirectToActionResult for redirects, JsonResult for JSON, ContentResult for text, FileResult for files, and status-code results such as NotFoundResult or BadRequestResult.

113
Mid-LevelIntermediate

What is ActionResult<T> and when is it useful?

ActionResult<T> allows an API action to return either a strongly typed value of T or an ActionResult such as NotFound(), BadRequest(), or Unauthorized().

114
Mid-LevelIntermediate

What is model binding in ASP.NET Core?

Model binding converts data from an HTTP request into .NET action parameters or model properties.

115
Mid-LevelIntermediate

What are model binding sources such as FromRoute, FromQuery, FromBody, FromForm, and FromHeader?

Binding source attributes explicitly tell ASP.NET Core where a value should come from.

116
Mid-LevelIntermediate

How does ASP.NET Core bind complex types?

For complex types, model binding creates an object and binds matching request values to its public settable properties or supported constructor parameters.

117
Mid-LevelIntermediate

What is ModelState?

ModelState stores information about model binding and model validation for the current request. It contains attempted values and any binding or validation errors.

118
Mid-LevelIntermediate

How does model validation work in ASP.NET Core?

Model validation runs after model binding and evaluates validation rules associated with the bound model.

119
Mid-LevelIntermediate

What is the ApiController attribute?

ApiController enables API-focused controller conventions and behaviors. It is normally applied to API controllers, often together with attribute routing.

120
Mid-LevelIntermediate

What is overposting and how can you prevent it?

Overposting occurs when a client submits fields that should not be editable and model binding assigns those values to properties on the bound object.

121
Mid-LevelIntermediate

What is the difference between ViewModel, DTO, and domain/entity model?

A ViewModel is shaped for a UI view and may combine display data, input fields, selections, or presentation-specific properties.

122
Mid-LevelIntermediate

How do HTTP verb attributes work in ASP.NET Core controllers?

Attributes such as HttpGet, HttpPost, HttpPut, HttpPatch, and HttpDelete restrict an action to specific HTTP methods and can also define route templates.

123
Mid-LevelIntermediate

What is the purpose of ValidateAntiForgeryToken in MVC?

Anti-forgery protection helps defend browser-based applications against Cross-Site Request Forgery (CSRF), where a malicious site causes a user's browser to submit an unwanted request using the user's existing authentication context.

124
Mid-LevelIntermediate

How do redirects work in ASP.NET Core MVC?

A redirect tells the client to make a new request to another URL. MVC provides helpers such as Redirect(), RedirectToAction(), RedirectToRoute(), and their permanent variants.

125
Mid-LevelIntermediate

What are best practices for routing, controllers, and model binding in ASP.NET Core?

Design routes to be stable, readable, and unambiguous. Use route constraints where they improve matching, and choose conventional or attribute routing according to the application's URL requirements.