KEMBAR78
Asp.net mvc | PPTX
ASP.NET MVC CRUSH COURSEERDEM ERGİN
MVC Pattern – What is it?MVC - Acronym for Model/View/ControllerInvented by TrygveReenskaug[1973 - 1978]Originally used as an architectural pattern for GUIs.The first implementation of MVC was as part of Smalltalk-80 class library.
MVC Pattern – How does it work?The Controller asks the Model for dataThe request hits the controllerModel213ControllerUserThe Model gives the data back to the ControllerThe controller formats the data and passes them to the ViewView45The view renders the HTML that needs to be sent to the client3
MVC Pattern – Who uses it?.NET has Spring.NET, MonoRailJava has Swing, Struts, Grails and othersPerl has Catalyst, Gantry, Jifty and othersPHP has Zend, Zoop, Agavi and othersPython has Django, Gluon, Pylon and othersRuby has Ruby on RailsApple has cocoa and cocoa touch for objective-c [Mac, iPhone]
MVC FrameworkHistoryBased on Python1970S….2003 RoR{ ASP.NET MVC }2009.3 MVC1 2010.4 MVC2
ASP.NET MVCIt’s not a replacement for asp.net webforms, it’s a new option [flavor]
 No more “postbacks” and “ViewStates”
 Built on top of ASP.NETAdvantagesClean URLs and HTML
More control over your html and JavaScript
Friendly URLS
More easily Testable Framework.
All ASP.Net providers still work [Membership, Session, Caching, etc]
Extensible and Pluggable [Support replacing any component]ASP.NET MVC Framework StructureASP.NET Abstractions(System.Web.Abstractions.dll)ASP.NET Routing(System.Web.Routing.dll)ASP.NET MVC(System.Web.Mvc.dll)
ASP.NET MVC Execution Process
DEMOCreate New ASP.NET MVC ProjectInvestigate ASP.NET MVC Structure
RoutingMVC+RR => the hidden character
ASP.NET MVC RoutingURL PatternsSetting Default Values for URL ParametersAdding Constraints to RoutesScenarios When Routing Is Not AppliedHow URLs Are Matched to RoutesAccessing URL Parameters in a Routed PageASP.NET Routing and SecurityASP.NET Routing versus URL Rewriting
Model [M]Validation
Controller [C]Controlling the flow of application execution
ASP.NET MVC ControllerController is a class consisting of a set of action methods. Responsible for Handling user interactionWorking with the modelsSelecting a view to renderSending model and information  to a particular viewMaking decisions for security, UI, redirects ... etc.The ASP.Net MVC requires the names of all controllers to end with the suffix  "Controller“  e.g.  HomeController, LoginController
ASP.NET MVC ControllerA controller action always returns an ActionResultWhat if I return an object ??Action return ActionResult which can beViewResult		=> HTML and markup.
EmptyResult=> no result.
RedirectResult	=> redirection to a new URL.
JsonResult		=> json result that can be used in an AJAX application.
JavaScriptResult	=> JavaScript script.
ContentResult	=> text result [and wraps any non ActionResult return Type].
FileContentResult	=> downloadable file [with the binary content].
FilePathResult	=> downloadable file [with a path].
FileStreamResult	=> a downloadable file [with a file stream]. Note: all public methods of a controller class consideredas action methods, if you don’t want a public method to be an action, mark it with [NonAction()] attribute
ASP.NET MVC Controller Filter
View [V]
ASP.NET MVC ViewResponsible for presentation, look & feel, formatting, sorting … etc. Interacts with model but shouldn’t make decisions No logic should go thereCode Behind exists but not recommendedNo View State, No Server ControlsHTML HelpersTakes the view data from the controllerCan be strong typed  Can be extended by implementing View EnginesAlways build your views !!!
An HTML Helper is just a method that returns a string.• Html.ActionLink()• Html.BeginForm()• Html.CheckBox()• Html.DropDownList()• Html.EndForm()• Html.Hidden()• Html.ListBox()• Html.Password()• Html.RadioButton()• Html.TextArea()• Html.TextBox()e.g.ASP.NET MVC View
Extensibility
The default ASP.NET MVC Pipeline21

Asp.net mvc