ASP.NET MVC Interview Questions for 3–5 Years Experience
The ASP.NET MVC questions asked of mid-level developers — the request life cycle, routing, ActionResult, ViewBag vs ViewData vs TempData, strongly typed views and validation.
At 3–5 years, MVC questions go past definitions into the request life cycle and the trade-offs between the framework's pieces. This is the full MVC follow-up chain, in the order it is usually asked.
Request handling
4 questionsASP.NET MVC is a web framework that implements the Model-View-Controller pattern. A controller handles the request, works with the model (the data and business logic), and returns a view (the HTML). It gives…
Read detailed answerThe request is matched by routing to a controller and action, the controller factory creates the controller, the action invoker runs authorization and action filters, performs model binding and validation,…
Read detailed answerRouting is the system that maps an incoming URL to a controller action, and (in reverse) generates URLs for a given action. You define routes either by convention (a pattern like {controller}/{action}/{id?})…
Read detailed answerActionResult is the base type for what a controller action returns. It represents a deferred command — “render this view”, “return this JSON”, “redirect there”, “send a 404” — that the framework executes…
Read detailed answerViews & state
3 questionsViewData is a string-keyed dictionary (ViewDataDictionary) for passing data from a controller to its view, valid for the current request only. ViewBag is a dynamic wrapper over the same dictionary — nicer…
Read detailed answerA strongly typed view declares the model type it expects with @model at the top. Inside, Model is that type, so you get IntelliSense, compile-time checking and strongly typed HTML/tag helpers like…
Read detailed answerYou annotate the model with validation attributes ([Required], [StringLength], [Range], [EmailAddress]…). During model binding the framework runs those rules and records failures in ModelState. Your action…
Read detailed answerMoving to Core
2 questionsASP.NET MVC 5 runs only on the Windows .NET Framework, is hosted in IIS through System.Web, and needs third-party libraries for dependency injection. ASP.NET Core is cross-platform, self-hosted through…
Read detailed answerMiddleware is a component that sits in the request pipeline. Each piece of middleware receives the HttpContext, can do work before and after the rest of the pipeline, and then either calls next() to pass the…
Read detailed answer