Mvc Framework 5

Updated : Jan 25, 2020 in Articles

Interview Questions on MVC

In this article, we will go through some of the basic important interview questions on MVC

1. What is MVC?

MVC stands for model, view, controller, and MVC is an architecture for building the Web Applications MVC Applications are light wait code compare to another code

Model: Model is nothing but business application logic simply it is a business entity model is an option in MVC without model also we will render views through the controller

View: the view is nothing but the user interface user request first it will hit the corresponding controller, thorough controller view will render and View displays data from the model to the user without model also controller will render the view this type of view we will call static view

Controller: In MVC controller is the heart of this (MVC) architecture controller will return the different types of result sets and it will process the incoming URL requests, it is class is deriving from System.web.mvc

2. What are the advantages of MVC

Main advantages of MVC architecture  is the separation (model-view-controller) of concern, Separation of concern means we divide the application(Web Applications) Model, view, controller and through this type of architecture we will build a different type of web application easily with slim code  

splits the application into class libraries level also, its means All business model is one class library and repository library and views and controller is one part this separation will make easy to build Applications

3. What is a controller in MVC?

the controller in MVC is the heart and it is a class, the controller will process the all incoming URL requests and controller is responsible for executing application flow when the user sending the request(for page ) it will interact the to model and fetching the data and return to view (render)

4. What are action verbs in MVC?

Action verbs in MVC [HttpPost] and [Httpget]

By default in MVC, All controller are action type [Httpget] its means if you are not mentioned on the controller is by default [Httpget ]

[Httpget]: HTTP get action verb it will create a query string by using the name and value pairs and HTTP get to have some restriction in the backward direction

[HttpPost]: HTTPPost has no such restriction and it can carry both texts as well as binary data.

Httpget and Httppost both we are using to establish the connection to the client to server and both actions verbs are we are using forward, backward direction

5. What are the Action results

Action result is a return type of controller methods in MVC and we have a different type of action results are available in MVC like the EmptyResult, JSONResult, JavascriptResult, PartialResult , ContentResult, RedirectResult ,  RedirectToRouteResult , ViewResult and Action result is a base data type of all above-derived types

6. What is the nonAction attribute in MVC?

by default attribute of all action methods in MVC, Httpget is an Action verb if we do not mention on the controller that is not a method so if we want to put the public method inside the controller we will mention the specified method on like a [NonAction] see the given below example

public ActionResult NonActionMethod()
     return View();

these non-action methods we will use some common code functionality and when we want a public method in a controller we will use it.

7. How we can maintain the sessions in MVC?

In MVC session, we will maint by using viewBag and ViewData and TempData

8. What is the difference between ViewBag and ViewData and TempData?

ViewBag and ViewData both are using to pass the data to a controller to view but viewBag is dynamic no need to required to casting but viewData required for casting at the view level

ViewBag and ViewData both we are using only within the single request only next subsequent request it is not possible to get the data so if you want to consume the data next subsequent request we will go through TempData with the help of keep method

9. What is the page life cycle or execution in MVC Application

Following the given below steps for MVC Application execution steps

  • sending the request for the application(or page )
  • Performs routing in rough.config
  • Implementing the MVC request handler
  • Implementing the Controller
  • Executing Controller
  • Invoke the action method
  • Executing the Result

10. What are the different return types of a controller action method in MVC?

  • View Result
  • Javascript Result
  • Redirect Result
  • Json Result
  • Content Result
  • partial Result
  • Empty result
  • RedirectToRoute Result
  • RedirectResult

Latest posts by DuttaluruVijayakumar (see all)
Like Love Haha Wow Sad Angry

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x