MVC tutorial

   The MVC (Model View Controller)Programming Model


MVC stands for Model, View and Controller. these are three components seprate application in MVC (Model , view and controller).

Here we will explain model, view and controller.




i) ModelModel represents the application core (for instance a list of database records),shape of the data and business logic. It maintains the data of the application. Model objects retrieve and store model state in a database.Model is a data and business logic that is called model.

ii)View-view represents the application to  displays the data (the database records) and View is a user interface. View display data using model to the user and also enables them to modify the data.

iii)Controller -Controller responsible to controlled the user request. Basically user interact with View, which in-tern keep appropriate URL request, its request will be handled by a controller. The controller renders the appropriate view with the model data as a response that is called controller and also The Controller handles the input (to the database records).


The list of ASP.NET MVC Briefly Explain and growing version :-


MVC Version
Visual Studio
.Net Version
Features
MVC 1.0
VS2008
.Net 3.5
  • MVC architecture with webform engine
  • HTML Helpers for HTML code
  • Ajax Helpers for AJax
  • Auto binding in application
MVC 2.0
VS 2008,
.Net 3.5/4.0
  • Area helpers
  • Asynchronous controller
  • Add Html helper methods with lambda  expression
  • Add new DataAnnotations attributes
  • Add mvc 2.0 Client side validation
  • Custom template
  • Add extra feature Scaffolding
MVC 3.0
VS 2010
.Net 4.0
  • Razor view engine
  • Global filters
  • Add Remote validation
  • Dependency resolver for IoC
  • Add ViewBag
MVC 4.0
VS 2010 SP1,
VS 2012
.NET 4.0/4.5
  • Add new mvc 4.0 feature as Mobile project template
  • Bundling and minification
  • Support for Windows Azure SDK in mvc 4.0
MVC 5.0
VS 2013
.NET 4.5
  • Authentication filters
  • Add Bootstrap support
  • Add New scaffolding items
  • Add ASP.Net Identity
MVC 5.2 - Current
VS 2013
.NET 4.5
  • New feature Attribute based routing
  • Add feature bug fixes and minor features upate in mvc 5.2


 Advantage of  using ASP.NET MVC

·        It is making very easy to complexity by dividing an application into the model, the view, and the controller.
·        ASP.Net MVC through to Enables full control over the rendered HTML and provides a clean separation of concerns.
·        Finally use control over HTML also means better permission for implementing compliance with evolving Web standards in ASP.Net MVC.
·        Full support adding more interactivity and responsiveness to existing application.

·        Available better support for test-driven development.

ASP.NET MVC Life Cycle:-



Here is briefly explain how to work life cycle feature ..

Routing: Routing is first process in MVC request cycle. Actually it is system that matches the request's URL with the registered URL pattern in the route table. As soon as matching pattern found in the route table, the routing engine immediately request to the corresponding IRouteHandler in repeat of request, the default being the MVChandler. It suppose the pattern is not found in the route table then the routing engine send a 404  HTTP code in respect of that request. 
Secondly when the request application start at first time it send some pattern to the route table to tell the routing system the access to be takes with any request where match these pattern. It has only one route table and this is setup in the Global.asax file of the project application.


Syntax:-
             Public static void RegisterRoutes(RouteCollection routes)
             {
               routes.IgnoreRoute("{resource} .axd/{*pathinfo}");
               routes.Maproute("Default" , //Route Name
               "{Controller}/{action}/{id}", URL with parameter
               new  { controller = "Home", action = "Index" id=UrlParameter.optional }                   //       Parameter defaults
               );
}

MVC Handler: Now let's discuss above MVC handler. As we all know MVCHandler is responsible for initiating the actual processing within ASP.Net MVC . It is implement IHttpHandler interface and other processes the request as follows.

Syntax:-
           Protected internal virtual void processRequest(HttpcontexBase httpcontex)
           {
            SecurityUtil.ProcessInApplicationTrust(delegate{ InController controller;
            InControllerFactory Factory;
            this.ProcessRequestInit(httpContext, out Controller, out factory);
            try
           {
            controller.Executive(this.RequestContext);
            }
            finally
            {
             factory.ReleaseController(controller);
             }
             });
             }


Action Execution:- When The controller is initiate into action its ActionInvoker determines the specific action to be invoked and then the action to be execute is chosen based where ActionNameSelectorAttribute (by default, it has in case than the same name as the action chosen) or ActionMethodSelectorAttribute (in case there is move than one method found and the correct one is chosen with the help of attribute) that is called action execute in MVC .

Syntax:-
            Public interface IActionInvoker()
{
                                  bool InvokeAction(ControllerContext controllerContext string actionName)
                                   
}


View Result:-  






No comments:

Post a Comment

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...