Luxoft ASP.NET MVC Interview Questions Answers

Mention what is the difference between adding routes, to a webform application and an MVC application?

To add routes to a webform application, we can use MapPageRoute() method of the RouteCollection class, where adding routes to an MVC application, you can use MapRoute() method.

Mention what are the two ways to add constraints to a route?

The two methods to add constraints to a route is

Use regular expressions
Use an object that implements IRouteConstraint Interface

Mention two instances where routing is not implemented or required?

Two instance where routing is not required are

When a physical file is found that matches the URL pattern
When routing is disabled for a URL pattern

Mention what are main benefits of using MVC?

There are two key benefits of using MVC

As the code is moved behind a separate class file, you can use the code to a great extent
As behind code is simply moved to.NET class, it is possible to automate UI testing. This gives an opportunity to automate manual testing and write unit tests.

Mention what is the advantages of MVC?

MVC segregates your project into a different segment, and it becomes easy for developers to work on
It is easy to edit or change some part of your project that makes project less development and maintenance cost
MVC makes your project more systematic

Mention what “beforFilter()”,“beforeRender” and “afterFilter” functions do in Controller?

beforeFilter(): This function is run before every action in the controller. It’s the right place to check for an active session or inspect user permissions.
beforeRender(): This function is called after controller action logic, but before the view is rendered. This function is not often used, but may be required If you are calling render() manually before the end of a given action
afterFilter(): This function is called after every controller action, and after rendering is done. It is the last controller method to run
Luxoft Most Frequently Asked ASP.NET MVC Interview Questions Answers
Luxoft Most Frequently Asked ASP.NET MVC Interview Questions Answers

Explain the role of components Presentation, Abstraction and Control in MVC?

Presentation: It is the visual representation of a specific abstraction within the application
Abstraction: It is the business domain functionality within the application
Control: It is a component that keeps consistency between the abstraction within the system and their presentation to the user in addition to communicating with other controls within the system

Explain the role of “ActionFilters” in MVC?

In MVC “ ActionFilters” help you to execute logic while MVC action is executed or its executing.

Explain what are the steps for the execution of an MVC project?

The steps for the execution of an MVC project includes

Receive first request for the application
Performs routing
Creates MVC request handler
Create Controller
Execute Controller
Invoke action
Execute Result

Explain what is Model-View-Controller?

MVC is a software architecture pattern for developing web application. It is handled by three objects Model-View-Controller.

Mention what does Model-View-Controller represent in an MVC application?

In an MVC model,

Model– It represents the application data domain. In other words applications business logic is contained within the model and is responsible for maintaining data
View– It represents the user interface, with which the end users communicates. In short all the user interface logic is contained within the VIEW
Controller– It is the controller that answers to user actions. Based on the user actions, 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 in which assembly is the MVC framework is defined?

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

Explain what is routing? What are the three segments for routing is important?

Routing helps you to decide a URL structure and map the URL with the Controller.

The three segments that are important for routing is

ControllerName
ActionMethodName
Parameter

Mention what is the difference between “ActionResult” and “ViewResult” ?

“ActionResult” is an abstract class while “ViewResult” is derived from “AbstractResult” class.  “ActionResult” has a number of derived classes like “JsonResult”, “FileStreamResult” and “ViewResult” .

“ActionResult” is best if you are deriving different types of view dynamically.

Explain how you can send the result back in JSON format in MVC?

In order to send the result back in JSON format in MVC, you can use “JSONRESULT” class.

Post a Comment

Previous Post Next Post