Date post: | 19-Jun-2015 |
Category: |
Technology |
Upload: | nonlinear-creations |
View: | 1,720 times |
Download: | 0 times |
2. What is Sitecore MVC? MVC as you may know it Sitecore MVC Why bother moving to Sitecore MVC?Resources 3. MVC as you may know it ASP.NET MVC- Model, View, Controller pattern- Interactions are routed through controllers, no post-backs- Views mapped to REST-friendly URLs- Light-weight, highly testable framework- No View State or server-based forms- Razor as the view engine- Convention over configurationToronto | Ottawa | New York | Calgary | So Paulo | Florianpolis 4 4. MVC as you know it: Route registrationpublic class MvcApplication : System.Web.HttpApplication{public static void RegisterRoutes(RouteCollection routes){routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute("Default", // Route name"{controller}/{action}/{id}", // URL with parametersnew { controller = "Home", action = "Index", id = "" } // Parameter defaults);}protected void Application_Start(){RegisterRoutes(RouteTable.Routes);}} 5. MVC as you know it: Controllerspublic class CustomerController : Controller{//// POST: /Customer/Edit/5[AcceptVerbs(HttpVerbs.Post)]public ActionResult Edit(int id, FormCollection collection){try{// TODO: Add update logic herereturn RedirectToAction("Index");}catch{return View();}}} 6. Sitecore MVC Sitecore MVC != ASP.NET MVC- Can use MVC routing, but defaults to using Sitecore as routing engine- Sitecore constructs page based on placeholder settings andpresentation details, just like with Web Forms- Individual components are defined as Controller Renderings or ViewRenderings- Instead of controller-per-page, Sitecore uses controller-per-rendering- Sitecore will run in MVC mode if:a) An MVC route is matchedb) Item layout is an MVC viewToronto | Ottawa | New York | Calgary | So Paulo | Florianpolis 7 7. Sitecore MVC: Controller vs. View Renderings Controller Rendering Executes Controller youbuild Can specify relative or fullyqualified class forcontroller Controller logic buildsmodel and determinesviews Controller is similar tocode-behind of an ASCX View Rendering Sitecore becomes theController Directly binds to anassociated .cshtml file Requires a model item,which binds directly torendering model class Useful for presentation-onlyrenderings (e.g. layoutrenderings)Toronto | Ottawa | New York | Calgary | So Paulo | Florianpolis 8 8. Why bother? Sitecore is going MVC- Sitecore 8: all UIs in SPEAK Developers want to work with MVC solutions- Separation of concerns (presentation vs code-behind)- Makes unit testing easier (if you do it right)- Re-use logic and models more easily between views- More control over rendered HTML (no view state garbage) Clients are beginning to ask for MVC solutions- Doing both > Only web forms Web Forms will go away (many years from now, but still)Toronto | Ottawa | New York | Calgary | So Paulo | Florianpolis 9 9. Resources 10. Sitecore Community Docs http://sitecore-community.github.io/docs/documentation/Sitecore%20MVC/index.html Contains links to online content submitted by the Sitecorecommunity. Key links:- Anything by Martina Welander- Creating a Visual Studio Project for Sitecore MVC- Sample Sitecore MVC project (used in Youtube tutorial videos)Toronto | Ottawa | New York | Calgary | So Paulo | Florianpolis 11 11. MSDN and others ASP.NET MVC Overview:- http://msdn.microsoft.com/en-us/library/dd381412(v=vs.100).aspx Getting Started with ASP.NET MVC 5- http://www.asp.net/mvc/overview/getting-started/introduction/getting-started PluralSight ASP.NET MVC 5 Fundamentals- http://www.pluralsight.com/courses/aspdotnet-mvc5-fundamentals 12. Jason St-Cyr Solution Architect and Sitecore MVP, nonlinear digitalLessons Learned Background in .NET software development and Application LifecycleManagement Contact me: [email protected] Around the web: Technical Blog:http://theagilecoder.wordpress.com LinkedIn Profile:http://www.linkedin.com/pub/jason-st-cyr/26/a73/645 Nonlinear Thinking:http://www.nonlinearcreations.com/Digital/how-we-think Twitter: @AgileStCyr 13. Nick Allen Solution Architect and Sitecore MVP, nonlinear digitalLessons Learned Background in .NET software development Contact me: [email protected] Around the web: Technical Blog:http://sitecorecreative.wordpress.com LinkedIn Profile:https://www.linkedin.com/in/nickallen80 Nonlinear Thinking:http://www.nonlinearcreations.com/Digital/how-we-think Twitter: @sitecoretweet