Wednesday 26 October 2016

model,view,controller technical concept and interview question answer.

MVC :



Model :

The model is the part of the application that handles the logic for the application data.
Often model objects retrieve data (and store data) from a database.

View :

The view is the parts of the application that handles the display of the often the views are created from the model  data.

Controller :

The controller is the part of the application that handles user interaction.
Typically controllers read data from a view ,control user input and send input data to the model.

The MVC separation helps you manage complex applications because you can focus on one aspect a time for example you can focus on the view without depending on the business logic.
It also makes it easier to test an application.

The MVC separation also simplifies group development. Different developers can work on the view ,the controller logic and the business logic in parallel.


Asp .net mvc gives you a powerful ,pattern based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable,agile development.

Asp .net mvc includes many features that enable fast TDD friendly development for creating sophisticated applications that use the latest web standards.


There are difference asp .net versions  like mvc1,mvc2,mvc3,mvc4,mvc5.

Difference between asp .net webforms and asp .net mvc

Asp .net web forms uses page controller pattern approach for rendering layout.

In this approach every page has its own controller i.e code behind file that processes the request.
On the other hand asp .net mvc uses front controller approach in this approach a common controller for all pages ,processes the requests.


Routing :

It is a mechanism to process the incoming url that is more descriptive and give desired response .
In this case UR is not mapped to specific files or folder as was the case of earlier days web sites .

There  are two types of routing

  Convention based routing
 Attribute based routing

Convention based routing :

To define this type of routing we call MapRoute method and set its unique name url pattern and specify some default values

The  routing is defined in App_start/RouteConfig.cs page like this
Routes.MapRoute(name:”default”,url:”{controller}/{action}/{id}”,defaults:new{controller=”home”,action=”index”,id=urlparameter optional});


Attribute based routing :

To define this type of routing we specify the route attribute  in the action method of the controller.


HttpHandler In Asp .Net MVC :

HttpHandler are responsible for handling Http Request.

HttpHandlers are classes that implement IHttpHandler and generate a response to HttpRequest




No comments:

Post a Comment