ASP.NET developer interview questions and how to answer them
ASP.NET developer interview questions test whether you can build and keep alive a real web application on Microsoft's stack: routing, model binding and validation, MVC versus Razor Pages versus Web API, sign-in and authorization, protection against common web attacks, caching, and often an older .NET Framework app that still pays the bills. Most loops add a practical task, such as a small API or a bug hunt in an existing project. Interviewers listen for how you reason about the request from browser to database and back, not for memorized framework trivia.
By Evin JohnPublished 11 min read
What an ASP.NET developer is hired to do
The title covers a wide range. At a bank or insurer it can mean an internal line-of-business app with Razor views, Windows sign-in and a SQL Server database that has grown for fifteen years. At a software company it usually means JSON APIs on ASP.NET Core consumed by a React or Angular front end and mobile apps. At an agency it can mean several client sites at once. What the jobs share is ownership of the web layer: endpoints and pages, the rules that decide who may call them, the shape of the responses, and how the app behaves under load and when something fails.
Hiring managers check three things. Fluency in the framework you will use on day one, including the parts that differ between the old .NET Framework and modern .NET. Web fundamentals that are not .NET-specific: HTTP verbs and status codes, cookies, CORS, caching headers and the usual attacks. And the habits of someone who will be trusted with production: tests around endpoints, logging that helps at 2 a.m., and changes small enough to review. Language and runtime depth (generics, the garbage collector, async internals) is usually asked too; the C# interview questions and .NET interview questions pages cover that side, so this guide stays on the web job.
How ASP.NET developer interviews usually run
- Recruiter or hiring manager screenWhich versions you have shipped on, whether you have worked on .NET Framework apps, front-end frameworks you touch, and the size of the systems you maintained.
- Technical conversationQuestions on routing, binding, filters, authentication and security, often driven by a project on your résumé: how did requests flow, where did validation live, what broke.
- Practical taskA take-home or a timed session: build a small REST API with validation and tests, add a feature to a starter MVC project, or find and fix bugs in code you have not seen before.
- Code review or pairingSome teams hand you a pull request with planted problems (an unvalidated input, a missing authorization check, a blocking call) and ask you to review it aloud.
- Team and behavioral roundHow you handle legacy code, disagreements in review, production incidents and estimates. Senior roles add a design discussion.
Choosing the right ASP.NET model
| Question | What it tests | What a strong answer shows |
|---|---|---|
| When would you build a screen with Razor Pages rather than MVC controllers and views? | Fit to the problem | Razor Pages for page-focused forms where each page owns its handlers; MVC when many actions share a controller, filters and views, or the team already has that structure |
| Controllers or minimal APIs for a new JSON service? | Current options | Minimal APIs for small, focused services with less ceremony; controllers when you want conventions, filters and model binding features the team already relies on. Either is a valid production choice |
| Where does Blazor fit, and what is the difference between its server and WebAssembly modes? | Breadth | Interactive UI in C#; server mode keeps state on the server over a live connection, WebAssembly runs in the browser and needs an API; newer versions let you mix render modes per component |
| What is the difference between ASP.NET on .NET Framework and ASP.NET Core? | History and constraints | Core is cross-platform, has built-in dependency injection, a middleware pipeline instead of System.Web, and runs on Kestrel. Web Forms and some System.Web features have no direct Core equivalent |
| When does server-side rendering beat a single-page app talking to your API? | Architecture judgment | Content and forms that need fast first load, search indexing or simple deployment favor server rendering; rich client interaction favors an SPA with a clear API contract |
| What is SignalR for? | Real-time features | Pushing updates to clients (notifications, dashboards, chat) over WebSockets with fallbacks; scaling out needs a backplane or a managed service so all servers see every message |
Routing, model binding and validation
- Conventional routing versus attribute routing: which do you use for an API? Attribute routes for APIs, because the URL sits next to the action and versioning is explicit. Conventional routes still suit classic MVC sites with predictable controller/action URLs.
- How does model binding decide where a value comes from? It looks at route values, query string, form fields and the body depending on the parameter type and attributes such as [FromBody], [FromQuery] and [FromRoute]. Say that complex types from a JSON body need [FromBody] unless the [ApiController] attribute infers it.
- What is over-posting, and how do you prevent it? A client sends fields you never meant to bind, such as IsAdmin. Bind to a request model that only has the allowed fields, then map to the entity, instead of binding straight to the database entity.
- Where should validation live? Simple shape rules on the request model (data annotations or a validation library), business rules in the service layer, and database constraints as the last line. Return a consistent error format, such as a problem details response with field errors.
- What does [ApiController] change? Automatic 400 responses when the model state is invalid, binding source inference and problem details for errors. Know how to customize the invalid-model response.
- A route returns 404 even though the action exists. How do you debug it? Check route templates and constraints, HTTP verb attributes, area names, conflicting routes and whether endpoint routing is registered in the right order. Logging at debug level shows which endpoint matched.
- How would you version a public API? URL segment, query string or header; pick one, document it, keep old versions running for an announced period, and test both versions in CI.
public record CreateOrderRequest(
[property: Required] string CustomerId,
[property: Range(1, 500)] int Quantity,
[property: Required, StringLength(40)] string Sku);
[ApiController]
[Route("api/orders")]
public class OrdersController(IOrderService orders) : ControllerBase
{
[HttpPost]
[Authorize(Policy = "CanPlaceOrders")]
public async Task<ActionResult<OrderDto>> Create(CreateOrderRequest request, CancellationToken ct)
{
// Invalid models never reach here: [ApiController] returns 400 with field errors.
var order = await orders.PlaceAsync(request, User, ct);
return CreatedAtAction(nameof(Get), new { id = order.Id }, order);
}
[HttpGet("{id:int}")]
public async Task<ActionResult<OrderDto>> Get(int id, CancellationToken ct) =>
await orders.FindAsync(id, User, ct) is { } dto ? dto : NotFound();
}Interviewers often ask you to talk through a snippet like this. Points worth making: the request type exposes only what a client may set, the policy check sits on the action, ownership checks (may this user see order 42?) belong in the service because a role alone does not answer them, and the cancellation token stops work when the client disconnects.
Filters, views and the MVC toolbox
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Name the filter types and the order they run in. | Request pipeline inside MVC | Authorization, resource, action, exception and result filters; action filters wrap the action, result filters wrap the response; exception filters only see MVC exceptions |
| Partial view, view component or tag helper: which for a shopping cart summary in the header? | Reusable UI | A view component, because it has its own logic and data access; partials for markup only; tag helpers to make HTML elements smarter |
| ViewData, ViewBag, TempData or a view model? | Passing data to views | A strongly typed view model by default; TempData for a message that survives one redirect, such as after a POST |
| What is the Post/Redirect/Get pattern? | Form handling | After a successful POST, redirect to a GET page so a refresh does not resubmit the form |
| How does Razor protect against cross-site scripting? | Output encoding | It HTML-encodes values by default; danger appears with Html.Raw, building HTML in strings, or putting user data into inline scripts and attributes without the right encoding |
| How do you share layout and sections across pages? | Razor structure | _Layout with RenderBody and optional sections, _ViewStart to set the layout, _ViewImports for shared using directives and tag helpers |
Authentication, authorization and web security
- Cookie authentication or JWT bearer tokens? Cookies for a server-rendered site on one domain, with HttpOnly, Secure and SameSite set. Bearer tokens for APIs called by SPAs, mobile apps or other services. Many apps use both, with separate schemes.
- What does ASP.NET Core Identity give you, and when would you use an external identity provider instead? User store, password hashing, lockout, two-factor and tokens. For single sign-on across apps or enterprise customers, an OpenID Connect provider such as Microsoft Entra ID or another identity service is usually the better owner of passwords.
- Roles, claims or policies? Roles are coarse. Policies built from claims and requirements express rules like 'must be in the finance department and have verified email'. Resource-based authorization handles 'only the author can edit this document'.
- How does antiforgery protection work, and when do you not need it? A token tied to the user's session is embedded in forms and checked on POST. Pure bearer-token APIs are not exposed to classic CSRF the same way, because the browser does not attach the token automatically.
- Explain CORS and a mistake you have seen with it. The browser asks the server which origins may call it. Common errors: allowing any origin together with credentials, or adding CORS middleware in the wrong place so preflight requests fail.
- How do you stop SQL injection in an app that still has hand-written SQL? Parameterized commands everywhere, no string concatenation of input, least-privilege database accounts, and a review rule that flags raw SQL.
- What would you log for a security incident, and what must you never log? Sign-ins, permission failures, admin actions and request IDs; never passwords, tokens, full card numbers or secrets.
- How do you store connection strings and API keys? Not in source control. User secrets on developer machines, environment variables or a managed secret store in hosted environments, with access through a managed identity where the platform supports it.
Performance, caching and production behavior
- Response caching, output caching, in-memory cache or a distributed cache? Response caching sets HTTP headers so browsers and proxies keep responses; output caching stores rendered responses on the server; an in-memory cache holds data inside one process; a distributed cache such as Redis shares it across instances. Say how each is invalidated.
- A page takes four seconds. Where do you start? Measure before guessing: application traces or a profiler to split time between database, outbound calls and rendering, then look for N+1 queries, missing indexes, large view models and synchronous calls.
- How do you return a large export without running out of memory? Stream rows to the response instead of building the whole file in memory, or move the export to a background job that emails a link.
- What is a health check endpoint, and what should it test? A cheap liveness check that the process answers, and a readiness check that dependencies such as the database respond, so a load balancer only routes to instances that can serve.
- How do you handle errors globally? Exception-handling middleware that logs with a correlation ID and returns a problem details body without stack traces; the developer exception page only in development.
- IIS, Kestrel behind a reverse proxy, containers or a managed app service? Know what forwarded headers do, why HTTPS redirection behaves differently behind a proxy, and how configuration differs per environment.
Legacy apps and migration questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Explain the Web Forms page lifecycle and ViewState to someone who has only used Core. | Legacy literacy | Server controls, postbacks and events such as Page_Load, and ViewState as hidden form data that can grow large and slow pages |
| A Web Forms app must stay for two more years. What do you improve first? | Pragmatism | Logging, tests around the riskiest pages, security patches and dependency updates, before any rewrite |
| How would you move an MVC 5 app to ASP.NET Core? | Migration planning | Inventory System.Web dependencies, upgrade libraries, move shared code to .NET Standard or modern .NET first, then migrate route by route with both apps running side by side behind a proxy |
| What tooling helps with an upgrade? | Practical knowledge | Microsoft's .NET Upgrade Assistant and analyzers flag incompatible APIs; they speed up the work but do not replace testing |
| What breaks most often in such a migration? | Experience | Session and authentication sharing between old and new apps, global.asax logic, HttpContext.Current usage, configuration from web.config and third-party libraries with no modern version |
| When is a rewrite the right call? | Judgment | Rarely all at once; when the old stack blocks security fixes or hiring and the app can be replaced in slices with measurable checkpoints |
Testing and the practical task
- How do you test a controller or endpoint? Unit tests for services with fakes, and integration tests that boot the app in memory with WebApplicationFactory and call real endpoints with an HTTP client, replacing external services and using a test database.
- What would you include in a take-home API in four hours? A clear README, input validation, consistent error responses, a few meaningful tests, sensible project layout, and notes on what you would do with more time. Reviewers read the README first.
- How do you test authorization rules? Integration tests with a test authentication handler that issues chosen claims, then assert 401, 403 and 200 for each case.
- You find a bug in someone else's code during the exercise. What do you do? Write a failing test that shows it, fix it with the smallest change, and mention it in your notes. Interviewers value the habit more than the fix.
Fictional example
- I worked on an MVC 5 claims portal for a regional insurer. After a release, agents started seeing other agents' draft claims for a few seconds after signing in. I pulled the logs by correlation ID and saw the drafts came from a cached partial view. A teammate had added output caching to the dashboard to fix slowness, but the cache did not vary by user. I disabled the cache by configuration within the hour, then added a test that signed in two different users and checked each saw only their own drafts. The longer fix was to cache the shared reference data instead and leave the user-specific part uncached. I also wrote a short note for the team on what may and may not be cached, and we added a review checklist item for any new caching attribute.
Behavioral questions for ASP.NET developers
- Tell me about the oldest code you have maintained and what you changed about how it was run.
- Describe a time you pushed back on a deadline because a security issue was not fixed.
- How do you review a pull request that is correct but hard to read?
- Tell me about an estimate you got badly wrong and what you learned.
- How do you work with front-end developers when the API contract has to change?
Use a clear situation, action and result shape for these; the behavioral question guide walks through it. If the role includes deploying to Azure App Service or managing the hosting yourself, the Azure cloud engineer guide covers the operations questions, and for test-heavy teams the automation tester guide shows how QA colleagues will exercise your endpoints. REST design in general is covered in the REST API guide.
A ten-day preparation plan
- Days 1 and 2: build a small API with two resources, validation, problem details errors and integration tests. Time yourself, as you would in a take-home.
- Days 3 and 4: add cookie and JWT authentication and one policy with a resource check. Write the 401 and 403 tests.
- Day 5: read a Web Forms or MVC 5 sample project and list what would block a move to Core.
- Days 6 and 7: practice explaining filters, caching options and CORS out loud in two minutes each.
- Days 8 and 9: prepare three project stories: a bug, a performance fix and a disagreement.
- Day 10: review the job posting again and match each requirement to an example you can describe.
Take-home tasks and code reviews reward clear narration, and that is easy to practise badly alone. Natively, an AI interview assistant for Mac and Windows, records a transcript of your mock technical conversation on your computer, so you can reread how you explained model binding or a migration plan and spot where you rambled. In practice sessions it can read a coding prompt from a screenshot and suggest an approach, and with Pro or the free trial it uses your résumé and the job description you add to shape suggestions around the version of ASP.NET in the posting. Your notes stay in its history for the next round.
Questions people ask
What questions are asked in an ASP.NET developer interview?
Expect questions on routing, model binding and validation, MVC versus Razor Pages versus Web API, authentication and authorization, CSRF, XSS and CORS, caching, and maintaining or migrating .NET Framework apps, plus a practical coding task.
Is ASP.NET Core asked differently from classic ASP.NET?
Yes. Core questions cover middleware, built-in dependency injection, Kestrel and minimal APIs. Classic ASP.NET questions cover Web Forms, ViewState, System.Web and how you would move such an app to modern .NET.
What is a typical ASP.NET take-home assignment?
Often a small REST API or a feature added to a starter MVC project, judged on validation, error handling, tests, structure and a clear README rather than on size.
How should I prepare for an ASP.NET developer interview?
Build a small API with authentication, validation and integration tests, practise explaining the request path and security choices aloud, and prepare stories about legacy code, a production bug and a performance fix.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
