MVC Developer Interview Preparation Guide
Download PDF

MVC Developer based Frequently Asked Questions in various MVC Developer job interviews by interviewer. These professional questions are here to ensures that you offer a perfect answers posed to you. So get preparation for your new job hunting

50 MVC Developer Questions and Answers:

1 :: Tell me in which assembly is the MVC framework is defined?

The MVC framework is defined in System.Web.Mvc.

2 :: Explain what are Filters in MVC?

In MVC, many times we would like to perform some action before or after a particular operation. For achieving this functionality, ASP.NET MVC provides feature to add pre and post action behaviors on controller's action methods.

Types of Filters:
ASP.NET MVC framework supports the following action filters:
☛ Action Filters: Action filters are used to implement logic that gets executed before and after a controller action executes.
☛ Authorization Filters: Authorization filters are used to implement authentication and authorization for controller actions.
☛ Result Filters: Result filters contain logic that is executed before and after a view result is executed. For example, you might want to modify a view result right before the view is rendered to the browser.
☛ Exception Filters: You can use an exception filter to handle errors raised by either your controller actions or controller action results. You can also use exception filters to log errors.

3 :: Tell us attribute based routing in MVC?

In ASP.NET MVC 5.0 we have a new attribute route, By using the "Route" attribute we can define the URL structure. For example in the below code we have decorated the "GotoAbout" action with the route attribute. The route attribute says that the "GotoAbout" can be invoked using the URL structure "Users/about".

☰ public class HomeController: Controller
☰ {
☰ [Route("Users/about")]
☰ publicActionResultGotoAbout()
☰ {
☰ return View();
☰ }
☰ }

4 :: Suppose if we have multiple filters, what’s the sequence for execution?

☛ Authorization filters
☛ Action filters
☛ Response filters
☛ Exception filters

5 :: Tell us what are the Difference between ViewBag&ViewData?

☛ ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.
☛ ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.

☛ ViewData requires typecasting for complex data type and check for null values to avoid error.
☛ ViewBag doesn't require typecasting for complex data type.

Calling of ViewBag is:
ViewBag.Name = "Hasan";

Calling of ViewData is :
ViewData["Name"] = " Hasan ";

6 :: Tell us what is display mode in MVC?

Display mode displays views depending on the device the user has logged in with. So we can create different views for different devices and display mode will handle the rest.

For example we can create a view “Home.aspx” which will render for the desktop computers and Home.Mobile.aspx for mobile devices. Now when an end user sends a request to the MVC application, display mode checks the “user agent” headers and renders the appropriate view to the device accordingly.

9 :: Tell me what is the adavantage of using ASP.NET routing?

In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.

An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.

10 :: Tell me what is MVC (Model View Controller)?

MVC is a software architecture pattern for developing web application. It is handled by three objects Model-View-Controller. Below is how each one of them handles the task.

☛ The View is responsible for the look and feel.
☛ Model represents the real world object and provides data to the View.
☛ The Controller is responsible for taking the end user request and loading the appropriate Model and View