MVC Interview Questions and Answers

Here is some questions and answers on MVC architecture pattern. these MVC Interview Questions and Answers are basic questions on MVC.

MVC Questions and Answers

    • What is Model-View-Controller?
      MVC is a software architecture pattern to develop web applications. MVC represent Model-View-Controller and there are three components.

      • ModelModel MVC represents the application data domain. Applications business logic is written within the model and model is responsible for maintaining data
      • View– View in MVC represents the user interface, with View the users communicates with Application. all the user interface logic is contained within the VIEW
      • Controller– Controller in MVC is the controller that reply to user actions. when request sent by users, the respective controller responds within the model and choose a view to render that display the user interface. The user input logic is contained with-in the controller

    • Explain the page life cycle of MVC?

      Below are the processed followed in the sequence –
      • App initialization
      • Routing
      • Instantiate and execute controller
      • Locate and invoke controller action
      • Instantiate and Render View.


    • In which assembly is the MVC framework defined in


    • Where are the routing rules defined in an MVC application?
      In Application_Start event in Global.asax file


    • What are the new features in Asp.Net MVC5 ?
      • Asp.Net One Identity
      • Web API 2
      • Filter overrides
      • Authentication Filters
      • ASP.NET SignalR 2.0
      • OAuth 2.0 Authorization in MVC 5
      • OData Improvements in MVC 5(Full support for $select, $expand, $batch, and $value)
      • One ASP.NET
      • Bootstrap in the MVC template


    • What is Razor View Engine?
      Razor was major update to render HTML to Display in MVC 3, and designed specifically for view engine syntax.
      File extension for Razor view are

      • .cshtml: for C# language
      • .vbhtml: for VB  language

      it start with symbol “@” and for writing comment Razor syntax use “@* “to indicate the starting of a comment and “*@ ” to ending the comment.
      An example is shown below.
      @* This is a Comment in Razor View *@


    • What you mean by Routing in MVC?
      Routing in MVC is a pattern matching mechanism of incoming requests to the URL patterns which are registered in route table. Class – “UrlRoutingModule” is used for the this process.
      RegisterRoutes()” is a method used for registering the routes which will be added in “Application_Start()” method of global.asax , which will be fired when the web application is  started.


    • What is the use of ViewModel in MVC?
      ViewModel is a class with properties, and used to bind it to strongly typed view. ViewModel can have the validation rules defined for its properties by using data annotations.


    • Name a few different return types of a controller action method?

      • ViewResult
      • JsonResult
      • RedirectResult
      • ContentResult
      • JavaScriptResult


    • What is the importance of NonActionAttribute?
      Generally, all public methods of a controller class are treated as action methods. If we want prevent this default behavior of controller class, just decorate the public method with NonActionAttribute.


    • What is the use of action filters in an MVC application?
      Action Filters allow us to add pre-action and post-action behavior to controller action methods.If you have multiple filters implemented, below are order in which these filters will be executed?

      • Authorization filters– Implements the IAuthorizationFilter attribute.
      • Action filters – Implements the IActionFilter attribute.
      • Response filters – Implements the IResultFilter attribute.
      • Exception filters– Implements the IExceptionFilter attribute.

    • What is role of “ActionFilters” in MVC?
      “ActionFilters” help you to execute logic while MVC action is executed or its executing.


    • What is the difference between Temp data, View, and View Bag?
      • Temp data: It helps to maintain data when you move from one controller to other controller.
      • View data: It helps to maintain data when you move from controller to view
      • View Bag: It’s a dynamic wrapper around view data


    • What filters are executed in the end?
      “Exception Filters” are executed in the end




Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 9 =

All Rights Reserved 2019 | DesignzRush (OPC) Pvt. Ltd.