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 Can We Navigate From One View To Other View Using Hyper-link? |
|
Answer» By using “ActionLink” method as SHOWN in the below code. The below code will create a simple URL which HELP tonavigate to the “Home” CONTROLLER and invoke the “GotoHome” ACTION. By using “ActionLink” method as shown in the below code. The below code will create a simple URL which help tonavigate to the “Home” controller and invoke the “GotoHome” action. |
|
| 2. |
Can We Map Multiple Url’s To The Same Action? |
|
Answer» Yes , you can , you just need to MAKE two ENTRIES with DIFFERENT KEY NAMES and specify the same controller and action Yes , you can , you just need to make two entries with different key names and specify the same controller and action |
|
| 3. |
Where Is The Route Mapping Code Written? |
|
Answer» The ROUTE MAPPING CODE is WRITTEN in the “global.asax” FILE. The route mapping code is written in the “global.asax” file. |
|
| 4. |
Can You Explain The Complete Flow Of Mvc? |
|
Answer» Below are the steps how control FLOWS in MVC (Model, view and controller) ARCHITECTURE:- Below are the steps how control flows in MVC (Model, view and controller) architecture:- |
|
| 5. |
How Can We Maintain Session In Mvc? |
|
Answer» Sessions can be maintained in MVC by 3 WAYS TEMPDATA ,viewdata and viewbag Sessions can be maintained in MVC by 3 ways tempdata ,viewdata and viewbag |
|
| 6. |
How Can We Restrict Mvc Actions To Be Invoked Only By Get Or Post? |
|
Answer» We can DECORATE the MVC ACTION by “HttpGet” or “HttpPost” attribute to restrict the type of HTTP CALLS. For instanceyou can see in the below code SNIPPET the “DisplayCustomer” action can only be invoked by “HttpGet”. If we try tomake Http post on “DisplayCustomer” it will throw an error. We can decorate the MVC action by “HttpGet” or “HttpPost” attribute to restrict the type of HTTP calls. For instanceyou can see in the below code snippet the “DisplayCustomer” action can only be invoked by “HttpGet”. If we try tomake Http post on “DisplayCustomer” it will throw an error. |
|
| 7. |
What Are The Benefits Of Using Mvc? |
|
Answer» There are two big benefits of MVC:-Separation of concerns is achieved as we are moving the code BEHIND to a separate class file. By moving the bindingcode to a separate class file we can REUSE the code to a GREAT extent.Automated UI testing is possible because now the behind code (UI INTERACTION code) has moved to a simple.NET class.This gives us opportunity to write unit tests and automate manual testing There are two big benefits of MVC:-Separation of concerns is achieved as we are moving the code behind to a separate class file. By moving the bindingcode to a separate class file we can reuse the code to a great extent.Automated UI testing is possible because now the behind code (UI interaction code) has moved to a simple.NET class.This gives us opportunity to write unit tests and automate manual testing |
|
| 8. |
Is Mvc Suitable For Both Windows And Web Application? |
|
Answer» MVC ARCHITECTURE is suited for web application than WINDOWS. For window application MVP i.e. “Model view PRESENTER”is more applicable. If you are using WPF and SL MVVM is more SUITABLE due to bindings. MVC architecture is suited for web application than windows. For window application MVP i.e. “Model view presenter”is more applicable. If you are using WPF and SL MVVM is more suitable due to bindings. |
|
| 9. |
Name A Few Different Return Types Of A Controller Action Method? |
|
Answer» The following are just a few RETURN types of a CONTROLLER action method. In general an action method can return an instance of a any class that derives from ACTIONRESULT class.
The following are just a few return types of a controller action method. In general an action method can return an instance of a any class that derives from ActionResult class.
|
|
| 10. |
Mention What Are Main Benefits Of Using Mvc? |
|
Answer» There are two key BENEFITS of using MVC There are two key benefits of using MVC |
|
| 11. |
Mention Two Instances Where Routing Is Not Implemented Or Required? |
|
Answer» TWO INSTANCE where ROUTING is not required are Two instance where routing is not required are |
|
| 12. |
Mention What Are The Two Ways For Adding Constraints To A Route? |
|
Answer» TWO METHODS for adding constraints to ROUTE is Two methods for adding constraints to route is |
|
| 13. |
Mention What Are The File Extensions For Razor Views? |
|
Answer» For razor VIEWS the file EXTENSIONS are For razor views the file extensions are |
|
| 14. |
Mention What Filters Are Executed In The End? |
|
Answer» In the END “EXCEPTION FILTERS” are EXECUTED. In the end “Exception Filters” are executed. |
|
| 15. |
Mention The Order Of The Filters That Get Executed, If The Multiple Filters Are Implemented? |
|
Answer» The FILTER ORDER WOULD be like The filter order would be like |
|
| 16. |
Mention What Is The Use Of The Default Route {resource}.axd/{*pathinfo}? |
|
Answer» This default ROUTE prevents request for a web RESOURCE FILE such as Webresource.axd or ScriptResource.axd from being PASSED to the CONTROLLER. This default route prevents request for a web resource file such as Webresource.axd or ScriptResource.axd from being passed to the controller. |
|
| 17. |
Mention What Is The Importance Of Nonactionattribute? |
|
Answer» All PUBLIC methods of a controller class are treated as the action method if you want to PREVENT this default method then you have to assign the public method with NONACTIONATTRIBUTE. All public methods of a controller class are treated as the action method if you want to prevent this default method then you have to assign the public method with NonActionAttribute. |
|
| 18. |
List Out The Types Of Result In Mvc? |
|
Answer» In MVC, there are twelve types of RESULTS in MVC where “ActionResult” CLASS is the main class while the 11 are their sub-types In MVC, there are twelve types of results in MVC where “ActionResult” class is the main class while the 11 are their sub-types |
|
| 19. |
Explain What Is The Difference Between View And Partial View? |
|
Answer» View :
Partial View :
View : Partial View : |
|
| 20. |
Explain How You Can Send The Result Back In Json Format In Mvc? |
|
Answer» In order to SEND the result back in JSON format in MVC, you can USE “JSONRESULT” CLASS. In order to send the result back in JSON format in MVC, you can use “JSONRESULT” class. |
|
| 21. |
Mention What Is The Difference Between “actionresult” And “viewresult”? |
|
Answer» “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 an abstract class while “ViewResult” is derived from “AbstractResult” class. “ActionResult” has a number of derived classes like “JsonResult”, “FileStreamResult” and “ViewResult” . |
|
| 22. |
Explain How You Can Implement Ajax In Mvc? |
|
Answer» In AJAX, MVC can be IMPLEMENTED in TWO ways In Ajax, MVC can be implemented in two ways |
|
| 23. |
What Is Partial View In Mvc? |
|
Answer» PARTIAL view in MVC renders a PORTION of view content. It is helpful in reducing CODE duplication. In simple terms, partial view allows to render a view within the parent view. Partial view in MVC renders a portion of view content. It is helpful in reducing code duplication. In simple terms, partial view allows to render a view within the parent view. |
|
| 24. |
Mention What Is The Difference Between Temp Data, View, And View Bag? |
|
Answer» •Temp DATA: It helps to maintain data when you shift from ONE controller to other controller. •Temp data: It helps to maintain data when you shift from one controller to other controller. |
|
| 25. |
Mention How Can Maintain Session In Mvc? |
|
Answer» Session can be MAINTAINED in MVC by three WAYS tempdata, viewdata, and VIEWBAG. Session can be maintained in MVC by three ways tempdata, viewdata, and viewbag. |
|
| 26. |
Explain Using Hyperlink How You Can Navigate From One View To Other View? |
|
Answer» By using “ActionLink” method as shown in the below CODE. The below code will make a SIMPLE URL which help to navigate to the “HOME” controller and invoke the “GotoHome” action. By using “ActionLink” method as shown in the below code. The below code will make a simple URL which help to navigate to the “Home” controller and invoke the “GotoHome” action. |
|
| 27. |
Explain How Routing Is Done In Mvc Pattern? |
|
Answer» There is a GROUP of routes called the RouteCollection, which CONSISTS of registered routes in the application.The RegisterRoutes method records the routes in this collection. A route defines a URL pattern and a handler to use if the request matches the pattern. The first parameter to the MapRoute method is the NAME of the route. The second parameter will be the pattern to which the URL matches. The THIRD parameter might be the default VALUES for the placeholders if they are not determined. There is a group of routes called the RouteCollection, which consists of registered routes in the application.The RegisterRoutes method records the routes in this collection. A route defines a URL pattern and a handler to use if the request matches the pattern. The first parameter to the MapRoute method is the name of the route. The second parameter will be the pattern to which the URL matches. The third parameter might be the default values for the placeholders if they are not determined. |
|
| 28. |
Explain What Is Routing? What Are The Three Segments For Routing Is Important? |
|
Answer» Routing helps you to decide a URL STRUCTURE and MAP the URL with the Controller. Routing helps you to decide a URL structure and map the URL with the Controller. |
|
| 29. |
Explain What Are The Steps For The Execution Of An Mvc Project? |
|
Answer» The steps for the execution of an MVC PROJECT includes The steps for the execution of an MVC project includes |
|
| 30. |
Explain The Role Of “actionfilters” In Mvc? |
|
Answer» In MVC “ ActionFilters” HELP you to EXECUTE logic while MVC ACTION is EXECUTED or its EXECUTING. In MVC “ ActionFilters” help you to execute logic while MVC action is executed or its executing. |
|
| 31. |
Mention The Advantages And Disadvantages Of Mvc Model? |
|
Answer» Advantages:
Disadvantages:
Advantages: Disadvantages:
|
|
| 32. |
Explain The Role Of Components Presentation, Abstraction And Control In Mvc? |
|
Answer» •Presentation: It is the visual representation of a specific ABSTRACTION WITHIN the application •Presentation: It is the visual representation of a specific abstraction within the application |
|
| 33. |
Mention What “beforfilter()”,“beforerender” And “afterfilter” Functions Do In Controller? |
|
Answer» •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. •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. |
|
| 34. |
Mention What Is The Advantages Of Mvc? |
|
Answer» •MVC segregates your PROJECT into a different segment, and it becomes easy for DEVELOPERS to work on. •MVC segregates your project into a different segment, and it becomes easy for developers to work on. |
|
| 35. |
Mention What Are The Two Ways To Add Constraints To A Route? |
|
Answer» The two methods to ADD constraints to a ROUTE is The two methods to add constraints to a route is |
|
| 36. |
Mention What Is The Difference Between Adding Routes, To A Web Form Application And An Mvc Application? |
|
Answer» 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. 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. |
|
| 37. |
List Out Few Different Return Types Of A Controller Action Method? |
|
Answer» •View RESULT •View Result |
|
| 38. |
Explain In Which Assembly Is The Mvc Framework Is Defined? |
|
Answer» The MVC FRAMEWORK is DEFINED in System.Web.Mvc. The MVC framework is defined in System.Web.Mvc. |
|
| 39. |
Mention What Does Model-view-controller Represent In An Mvc Application? |
|
Answer» In an MVC model, In an MVC model, |
|
| 40. |
Explain What Is Model-view-controller? |
|
Answer» MVC is a SOFTWARE ARCHITECTURE pattern for developing web APPLICATION. It is handled by THREE objects Model-View-Controller. MVC is a software architecture pattern for developing web application. It is handled by three objects Model-View-Controller. |
|