InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How will you explain the concept of RenderBody and RenderPage of MVC? |
|
Answer» RENDERBODY can be CONSIDERED as a ContentPlaceHolder of web forms. It is available on the layout page and will be responsible for rendering the child pages/views. On the other hand, the layout page contains a single RenderBody() method. Multiple RenderPage() can reside within the Layout page. Additional Interview Resources:
|
|
| 2. |
Point out the two instances where you cannot use routing or where routing is not necessary |
|
Answer» The 2 SITUATIONS where routing is not used or not necessary are:
|
|
| 3. |
What are the areas of benefits in using MVC? |
|
Answer» The area of benefits of using MVC is:
|
|
| 4. |
How can you implement the MVC forms authentication? |
|
Answer» Authentication in forms is added in ORDER to include a layer of security to access the user for a specific SERVICE. This authentication is done by verifying the user’s IDENTITY through the credentials such as USERNAME with password or email with a password. The code snippet will look something like this: <system.web> <authentication mode = "Forms" > <formsloginUrl = "Login.aspx" protection = "All" timeout = "30" name = ".ASPXAUTH" path = "/" requireSSL = "false" defaultUrl = "default.aspx" cookieless = "UseDeviceProfile" /> </authentication> </system.web> |
|
| 5. |
What are the rules of Razor syntax? |
|
Answer» The primary rules for creating Razor are: |
|
| 6. |
Explain briefly the GET and POST Action types? |
Answer»
|
|
| 7. |
Define Default Route in MVC? |
|
Answer» The default Route of PROJECT templates in MVC includes a generic route that makes use of the given URL resolution for breaking the URL BASED on the REQUEST into 3 tagged SEGMENTS. URL: “{controller} / {action} / {id}” |
|
| 8. |
Explain briefly the use of ViewModel in MVC? |
|
Answer» ViewModel can be defined as a plain class having different PROPERTIES. It is used for binding a view that is STRONGLY TYPED. ViewModel CONSISTS of various VALIDATION rules for defining the properties of practising data annotation. |
|
| 9. |
Point out the different stages a Page life cycle of MVC has? |
|
Answer» The DIFFERENT steps or stages of the page life-cycle of MVC are: |
|
| 10. |
Explain briefly the two approaches of adding constraints to an MVC route? |
|
Answer» For adding CONSTRAINTS to an MVC route, the 2 different approaches are: |
|
| 11. |
Mention the possible file extensions used for razor views? |
|
Answer» The different file extensions that are used by razor views are:
|
|
| 12. |
Which type of filters are executed in the end while developing an MVC application? |
|
Answer» In the end, while DEVELOPING an MVC APPLICATION, the “Exception FILTERS” are EXECUTED. |
|
| 13. |
What is ViewStart? |
|
Answer» A new layout called _ViewStart is introduced by the Razor View Engine that is applied to all VIEWS automatically. ViewStart is executed at the very BEGINNING followed by the START rendering as WELL as other views. Example: @ { Layout = "~/ Views/ SHARED/ _ file.cshtml"; } <html> <head> <meta name="viewport" /> <title> InitialView </title> </head> <body> …. </body></html> |
|
| 14. |
When multiple filters are used in MVC, how is the ordering of execution of the filters done? |
|
Answer» The ORDER in which FILTERS are used:
|
|
| 15. |
Define Scaffolding in MVC? |
|
Answer» Scaffolding can be defined as an ASP.NET’s code-generation FRAMEWORK used in WEB applications. Scaffolding is used in developing MVC applications when ANYONE wants to rapidly enhance the code that intermingles with the application’s data MODEL. Scaffolding can ALSO lower the quantity of time for developing a standard data operation in the application. |
|
| 16. |
What is used to handle an error in MVC? |
|
Answer» Error handling is usually done USING Exception handling, whether it’s a Windows Forms application or a web application. The HandleError attribute is used, which helps in providing built-in exception filters. The HandleError attribute of ASP.NET can be functional over the action METHOD as well as Controller at its GLOBAL level. Example of implementation: PUBLIC static void RegGlobalFilters(Global_FilterCollection filt) { filt.Add(new HandleErrorAttribute());} protected void Application_Start() { AreaRegn.RegisterAllAreas(); RegGlobalFilters(Global_Filters.Filters); RegisterRoutes(Route_Table.Routes); } |
|
| 17. |
Mention the significance of NonActionAttribute? |
|
Answer» The various PUBLIC methods that are associated with the controller class are considered to be the action method. For PREVENTING the DEFAULT method, you have to allocate its public method with NonActionAttribute. |
|
| 18. |
Define the concept of Filters in MVC? |
|
Answer» There are situations where I want to implement some logic either prior to the execution of the action method or right after it. In that SCENARIO, the Action Filters are USED. Filters are used to determine the logic needed for executing before or after the action method gets executed. Action methods MAKE use of the action filters as an ATTRIBUTE. Different types of MVC action filters are:
|
|
| 19. |
Make a differentiation between View and Partial View? |
||||||||||
|
Answer» The major DIFFERENTIATION between View and Partial View is as FOLLOWS:
|
|||||||||||
| 20. |
Which class will you use for sending the result back in JSON format in MVC? |
|
Answer» For sending back the RESULT in JSON format in any MVC application, you have to implement the “JSONRESULT” CLASS in your application. |
|
| 21. |
Describe ASP.NET MVC? |
|
Answer» The term ASP.NET MVC can be defined as a WEB APPLICATION framework that is very lightweight and has high testable features. ASP.NET supporting MVC USES 3 separate components in its application. These are the Model, VIEW, and CONTROLLER. |
|
| 22. |
Why are Minification and Bundling introduced in MVC? |
|
Answer» Two new techniques have been included in MVC, known as Bundling and minification, whose primary function is to progress the request load TIME. It advances the load time by dipping the number of requests sent to the server as well as reducing the REQUESTED asset’s (JavaScript and CSS) size. |
|
| 23. |
Define Output Caching in MVC? |
|
Answer» Output Caching is an approach USED for improving the performance of an MVC application. It is used for enabling its users to CACHE the data sent back by the controller method so that the data used earlier does not get generated each time while INVOKING the same controller method. It has advantages to use Output Caching as it cuts down database server round trips, minimizes server round trips as well as reduces the NETWORK traffic. |
|
| 24. |
What is TempData in MVC? |
|
Answer» TEMPDATA can be defined as a dictionary object used for STORING data for a short period of TIME. This is the MVC’s TempDataDictionary class which acts as a Controller base-class’s instance property. TempData has the ability to PRESERVE data for an HTTP request. |
|
| 25. |
Explain briefly what you understand by separation of concern. |
|
Answer» SEPARATION of CONCERNS can be defined as ONE of the core features as well as benefits of using MVC and is supported by ASP.NET. Here, the MVC framework offers a distinct detachment of the different concerns such as User Interface (UI), data and the business LOGIC. |
|
| 26. |
What is Spring MVC? |
|
Answer» The Spring MVC or Spring Web MVC can be defined as a framework that provides a “Model View Controller” (MVC) ARCHITECTURE in the application as well as ready components IMPLEMENTED for developing adjustable and adaptable web applications. It is ACTUALLY a Java-based framework intended to build web applications. It works on the Model-View-Controller design approach. This framework ALSO makes use of all the elementary traits of a core Spring Framework such as DEPENDENCY injection, lightweight, integration with other frameworks, inversion of control, etc. Spring MVC has a dignified resolution for implementing MVC in Spring Framework with the use of DispatcherServlet. |
|
| 27. |
How will you differentiate between ActionResult and ViewResult? |
||||||||
|
Answer» Some COMMON differentiation between ACTIONRESULT and ViewResult is:
|
|||||||||
| 28. |
Mention & explain the different approaches you will use to implement Ajax in MVC? |
|
Answer» There are 2 different approaches to implementing Ajax in MVC. These are:
|
|
| 29. |
Explain the 3 concepts in one line; Temp data, View, and Viewbag? |
| Answer» | |
| 30. |
How will you navigate from one view to another view in MVC? Explain with a hyperlink example. |
|
Answer» We will make use of the ActionLink method which will help us to NAVIGATE from ONE VIEW to another. Here is an example of NAVIGATING the Home controller by INVOKING the Go to Home action. He is how we can code it: <%=Html.ActionLink("Home","GoTo Home")%> |
|
| 31. |
How is the routing carried out in MVC? |
|
Answer» The RouteCollection contains a set of routes that are responsible for registering the routes in the application. The RegisterRoutes method is used for recording the routes in the COLLECTION. The URL patterns are defined by the routes and a HANDLER is used which checks the request matching the pattern. The MVC routing has 3 parameters. The first parameter determines the name of the route. The second parameter determines a specific pattern with which the URL MATCHES. The third parameter is responsible for providing default VALUES for its placeholders. |
|
| 32. |
What are the different properties of MVC routes? |
|
Answer» MVC ROUTES are accountable for governing which controller method will be executed for a given URL. Thus, the URL comprises the following properties:
|
|
| 33. |
What are the 3 important segments for routing? |
|
Answer» The 3 IMPORTANT SEGMENTS for ROUTING are:
|
|
| 34. |
What is the concept of routing in MVC? |
|
Answer» MVC ROUTING can be defined as a pattern-matching scheme that is USED for mapping incoming REQUESTS of browsers to a definite MVC controller action. |
|
| 35. |
How to execute any MVC project? Explain its steps. |
|
Answer» For executing an MVC project, the STEPS FOLLOWED are:
|
|
| 36. |
What is the use of ActionFilters in MVC? |
|
Answer» ActionFilters are used for EXECUTING the logic while MVC action is EXECUTED. Furthermore, action filters permit the IMPLEMENTATION of pre and post-processing logic and action methods. |
|
| 37. |
How will you define the 3 logical layers of MVC? |
|
Answer» The 3 LOGICAL layers of MVC can be defined as follows: |
|
| 38. |
Explain in brief the difference between adding routes in a webform application & an MVC application? |
|
Answer» We make use of the MapPageRoute() which is of the RouteCollection CLASS for ADDING routes in a WEBFORM APPLICATION. Whereas, the MapRoute() method is USED for adding routes to an MVC application. |
|
| 39. |
What do you mean by partial view of MVC? |
|
Answer» A partial view can be defined as a portion of HTML that is CAREFULLY injected into an existing DOM. Partial VIEWS are commonly implemented for componentizing RAZOR views, making them simpler to build and update. Controller methods can also directly RETURN the partial views. |
|
| 40. |
How will you maintain the sessions in MVC? |
|
Answer» The sessions of an MVC can be MAINTAINED in 3 possible WAYS:
|
|
| 41. |
Explain in brief the role of different MVC components? |
|
Answer» The different MVC components have the FOLLOWING roles:
|
|
| 42. |
Explain some benefits of using MVC? |
|
Answer» Some common benefits of MVC are:
|
|
| 43. |
What are the various steps to create the request object? |
|
Answer» In order to create a REQUEST OBJECT, we have to go through 4 DIFFERENT steps. These are:
|
|
| 44. |
Explain the MVC Application life cycle. |
|
Answer» WEB applications usually have 2 PRIMARY execution steps. These are:
The same thing can be related to MVC applications also whose LIFE cycle has 2 foremost PHASES:
|
|
| 45. |
Name the assembly in which the MVC framework is typically defined. |
|
Answer» In the System.Web.MVC, the MVC FRAMEWORK is USUALLY DEFINED. |
|
| 46. |
What are the different return types used by the controller action method in MVC? |
|
Answer» The VARIOUS RETURN types of controller action METHODS in MVC are:
|
|
| 47. |
Explain Model, View and Controller in Brief. |
Answer»
|
|