1. What is MVC (Model view controller)?
MVC is an architectural pattern which separates the representation and user interaction. It’s divided into three broader sections, Model, View, and Controller. Below is how each one of them handles the task.
* The View is responsible for the look and feel.
Ex: We might create a Product "Edit" view that surfaces textboxes, dropdowns and checkboxes based on the current state of a product object.
* Model represents the real world object and provides data to the View.
Ex: We might have a product class that is used to represent order data from the Products table inside SQL.
* The Controller is responsible for taking the end user request and loading the appropriate Model and View.
In the MVC application, the views are used only for displaying the information whereas the controllers are used for handling and responding to user input and interaction.
2. Explain MVC application life cycle?
In a MVC application, no physical page exists for a specific request. All the requests are routed to a special class called the Controller. The controller is responsible for generating the response and sending the content back to the browser. Also, there is a many-to-one mapping between URL and controller.
When you request a MVC application, you are directly calling the action method of a controller.
When you request http://MVCApplication/HomeController/HomeMethod, you are actually calling Home Controller’s Home Method.
Life cycle of MVC request is a series of steps involved in processing client request. There are seven main steps that happen when you make a request to Asp.net MVC web applications.
For more information about MVC Life cycle Click here.
3. What are the advantages of using asp.net MVC?
* Extensive support for test-driven development(TDD). With asp.net MVC, views can also be very easily unit tested.
* Complex applications can be easily managed
* Separation of concerns. Different aspects of the application can be divided into Model, View and Controller
* ASP.NET MVC views are light weight, as they do not use viewstate.
* You can design the application with a rich routing infrastructure as it uses a Front Controller pattern that processes Web application requests through a single controller.
4. What are HTML helpers in MVC?
HTML Helper is just a method that returns a HTML string. The string can represent any type of content that you want. For example, you can use HTML Helpers to render standard HTML tags like HTML <input>, <button> and <img> tags etc.
There are three types of HTML helpers
* Inline Html Helpers
* Built-In Html Helpers(The Built-In Html helpers can be divided into three categories)
* Standard Html Helpers
* Strongly Typed HTML Helpers
* Templated HTML Helpers
* Custom Html Helpers
Note : Please share your interview questions and answers here firstname.lastname@example.org or email@example.com