YouTube Link: https://youtu.be/Mlkgr6SOkUM
** Edureka Online Courses: https://www.edureka.co **
This Edureka video on "Top 40 MVC Interview Questions and Answers" will help you to prepare yourself for the MVC Questions asked in Interviews. It covers mvc questions for beginners, intermediate and experienced professionals. Below topics are covered in this video:
Beginner Level MVC Interview Questions
Intermediate Level MVC Interview Questions
Advanced Level MVC Interview Questions
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
4. www.edureka.cowww.edureka.co
Explain what is MVC01
The MVC architectural pattern separates
an application into three components –
Model, View, and Controller. In this
pattern, the model represents the shape
of the data and business logic. It
maintains and preserves the data of the
application.
5. www.edureka.cowww.edureka.co
What does Model-View-Controller represent in an MVC application?
02
Model represents the application data domain
View represents the user interface with which the end user communicates
Controller controls and answers to the user actions
6. www.edureka.cowww.edureka.co
List out a few different return types of a controller action method?03
Few return types are:
• View Result
• Javascript Result
• ReDirect Result
• JSON Result
• Content Result
7. www.edureka.cowww.edureka.co
What are the advantages of MVC?04
Multiple view
support
Change
Accommodation
SoC – Separation
of Concerns
More Control
Testability
Lightweight
8. www.edureka.cowww.edureka.co
Explain the role of Presentation, Abstraction and Control in MVC05
Abstraction: It is the business domain functionality within the application.
Presentation: It is the visual representation of a specific abstraction within the
application.
Control: It is a component that keeps consistency between the abstraction
within the system and their presentation to the user.
10. www.edureka.cowww.edureka.co
What is MVC Application Life Cycle?07
Any web application has two main execution steps, first understanding the
request and depending on the type of the request, sending out an appropriate
response. MVC application life cycle has two main phases, first creating the
request object and second sending the response to the browser.
12. www.edureka.cowww.edureka.co
What is Spring MVC?09
It is a Java framework which is used to build web applications. It follows the Model-View-
Controller design pattern. Not just that, it also implements all the basic features of a
core Spring Framework like Inversion of Control, Dependency Injection. Spring MVC
provides a dignified solution to use MVC in Spring Framework by the help
of DispatcherServlet. In this case, DispatcherServlet is a class that receives the incoming
request and maps it to the right resource such as Controllers, Models, and Views.
13. www.edureka.cowww.edureka.co
What is ASP.NET MVC?10
ASP.NET MVC is a web application Framework. It is lightweight and highly
testable Framework. MVC separates an application into three components
— Model, View, and Controller.
15. www.edureka.cowww.edureka.co
What are filters?12
Sometimes we want to execute some logic either before the execution of
the action method or after the execution. We can use Action Filter for such
kind of scenario. Filters define the logic which is executed before or after
the execution of the action method. Action Filters are attributes which we
can apply to the action methods.
16. www.edureka.cowww.edureka.co
What is Partial View in MVC?13
A partial view is a chunk of HTML that can be safely inserted into an
existing DOM. Most commonly, partial views are used to
componentize Razor views and make them easier to build and update.
17. www.edureka.cowww.edureka.co
What is MVC routing?14
App Initialization
Routing
Instantiate and execute controller
Instantiate and render the view
Locate and invoke a controller
18. www.edureka.cowww.edureka.co
What is the use of View Model in MVC?15
ViewModel is a plain class with properties, which is used to bind it to a strongly-
typed view. ViewModel can have the validation rules defined for its properties using
data annotation.
20. www.edureka.cowww.edureka.co
What is Database first approach In MVC using Entity Framework?16
Database First Approach is an alternative or substitutes to the Code First and Model
First approaches to the Entity Data Model. The Entity Data Model creates model codes
(classes, properties, DbContext, etc.) from the database in the project and
that class behaves as the link between database and controller.
21. www.edureka.cowww.edureka.co
What do you mean by MVC Scaffolding?17
Scaffolding is a code generation framework for ASP.NET Web applications. Visual
Studio includes pre-installed code generators for MVC and Web API projects.
22. www.edureka.cowww.edureka.co
What Is the concept of Razor in ASP.NET MVC?18
ASP.NET MVC has always supported the concept of “view engines” – which are
the pluggable modules that implement different template syntax options. The
“default” view engine for ASP.NET MVC uses the same .aspx/.ascx/. master file
templates as ASP.NET WebForms. Other popular ASP.NET MVC view engines are
Spart & Nhaml. Razor is the new view-engine introduced by MVC 3.
24. www.edureka.cowww.edureka.co
What is GET and POST Action types?20
GET Action Type:
GET is used to request
data from a specified
resource. With all the GET
requests, we pass the URL,
which is compulsory;
however, it can take up the
following overloads.
POST Action Type:
The POST is used to submit
data to be processed to a
specified resource. With
all the POST requests, we
pass the URL, which is
essential and the data.
However, it can take up the
following overloads.
26. www.edureka.cowww.edureka.co
Mention the benefits of Area in MVC22
• It allows us to organize models,
views, and controllers into separate
functional sections of the
application, such as administration,
billing, customer support and much
more.
• It is easy to integrate with other
Areas created by another.
• Also, easy for unit testing.
28. www.edureka.cowww.edureka.co
What are the two ways for adding constraints to the route?24
Using Regular Expressions
Using an object that implements IRoute Interface
29. www.edureka.cowww.edureka.co
How to implement Validation in MVC?25
We can easily implement validation in MVC application by
using the validators defined in
the System.ComponentModel.DataAnnotations namespace
30. www.edureka.cowww.edureka.co
Mention 2 instances where routing is not implemented or required?26
When a physical file is found that matches the URL Pattern
When routing is disabled for a URL Pattern
32. www.edureka.cowww.edureka.co
What is the use of Peek and Keep in TempData28
Once “TempData” is read in the current request, it’s not available in the subsequent
request. If we want “TempData” to be read and also available in the subsequent request
then after reading we need to call “Keep” method as shown in the code below.
@TempData["MyData"];
TempData.Keep("MyData");
OR
string str = TempData.Peek("Td").ToString();
34. www.edureka.cowww.edureka.co
How can you detect that an MVC request is called by a GET or POST?30
public ActionResult SomeAction(){
if (Request.HttpMethod == "POST"){
return View("SomePage");
}
else{
return View("SomeOtherPage");
}
}
36. www.edureka.cowww.edureka.co
What are the main Razor Syntax31
Razor code blocks are enclosed in @{…}
Inline expressions (variables and functions) start
with @
Code statements end with a semicolon
Variables are declared with the var keyword
Strings are enclosed with quotation marks
C# code is case senstive
37. www.edureka.cowww.edureka.co
How do you implement Forms authentication in MVC?32
Authentication is giving access to the user for a specific
service by verifying his/her identity using his/her credentials
like username and password or email and password. It
assures that the correct user is authenticated or logged in for
a specific service and the right service has been provided to
the specific user based on their role.
38. www.edureka.cowww.edureka.co
Can you explain Render page and Render Body in MVC?33
RenderBody is like ContentPlaceHolder in web
forms. This will exist in layout page and it will
render the child pages/views. Layout page will
have only one RenderBody() method. RenderPage
also exists in Layout page and multiple
RenderPage() can be there in the Layout page.
40. www.edureka.cowww.edureka.co
How to perform Exception Handling in MVC35
public class HomeController : Controller{
protected override void OnException(ExceptionContext
filterContext){
Exception ex = filterContext.Exception;
filterContext.ExceptionHandled = true;
var model = new
HandleErrorInfo(filterContext.Exception,
"Controller","Action");
filterContext.Result = new ViewResult()
{
ViewName = "Error",
ViewData = new ViewDataDictionary(model)
};
}
}
44. www.edureka.cowww.edureka.co
What is a glimpse?39
Glimpse is NuGet packages
which help in finding
performance, debugging
and diagnostic information.
Glimpse can help you get
information about timelines,
model binding, routes,
environment, etc.