SlideShare a Scribd company logo
1 of 14
What is Sitecore MVC? 
Out on the razor’s edge 
Prepared by: Jason St-Cyr and Nick Allen
What is Sitecore MVC? 
• MVC as you may know it 
• Sitecore MVC 
• Why bother moving to Sitecore MVC? 
Resources
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 configuration 
Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 4
MVC as you know it: Route registration 
public 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 parameters 
new { controller = "Home", action = "Index", id = "" } // Parameter defaults 
); 
} 
protected void Application_Start() 
{ 
RegisterRoutes(RouteTable.Routes); 
} 
}
MVC as you know it: Controllers 
public class CustomerController : Controller 
{ 
// 
// POST: /Customer/Edit/5 
[AcceptVerbs(HttpVerbs.Post)] 
public ActionResult Edit(int id, FormCollection collection) 
{ 
try 
{ 
// TODO: Add update logic here 
return RedirectToAction("Index"); 
} 
catch 
{ 
return View(); 
} 
} 
}
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 and 
presentation details, just like with Web Forms 
- Individual components are defined as Controller Renderings or View 
Renderings 
- Instead of ‘controller-per-page’, Sitecore uses ‘controller-per-rendering’ 
- Sitecore will run in “MVC mode” if: 
a) An MVC route is matched 
b) Item layout is an MVC view 
Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 7
Sitecore MVC: Controller vs. View Renderings 
• Controller Rendering 
• Executes Controller you 
build 
• Can specify relative or fully 
qualified class for 
controller 
• Controller logic builds 
model and determines 
views 
• Controller is similar to 
code-behind of an ASCX 
• View Rendering 
• Sitecore becomes the 
Controller 
• Directly binds to an 
associated .cshtml file 
• Requires a model item, 
which binds directly to 
rendering model class 
• Useful for ‘presentation-only’ 
renderings (e.g. layout 
renderings) 
Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 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 | São Paulo | Florianópolis 9
Resources
Sitecore Community Docs 
• http://sitecore-community. 
github.io/docs/documentation/Sitecore%20MV 
C/index.html 
• Contains links to online content submitted by the Sitecore 
community. 
• 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 | São Paulo | Florianópolis 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
Jason St-Cyr 
 Solution Architect and Sitecore MVP, nonlinear digital 
Lessons Learned 
 Background in .NET software development and Application Lifecycle 
Management 
 Contact me: jst-cyr@nonlinear.ca 
 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
Nick Allen 
 Solution Architect and Sitecore MVP, nonlinear digital 
Lessons Learned 
 Background in .NET software development 
 Contact me: nallen@nonlinear.ca 
 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

More Related Content

What's hot

SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
Jon Galloway
 
Fun with Social, Windows 8 and Javascript
Fun with Social, Windows 8 and JavascriptFun with Social, Windows 8 and Javascript
Fun with Social, Windows 8 and Javascript
Joris Poelmans
 

What's hot (20)

Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
SharePoint 2010 Web Content Management - The Developer Story
SharePoint 2010 Web Content Management - The Developer StorySharePoint 2010 Web Content Management - The Developer Story
SharePoint 2010 Web Content Management - The Developer Story
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
 
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin TimmermannO365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
6 The UI Structure and The Web API
6 The UI Structure and The Web API6 The UI Structure and The Web API
6 The UI Structure and The Web API
 
Using the Kentico CMS API
Using the Kentico CMS APIUsing the Kentico CMS API
Using the Kentico CMS API
 
SharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSharePoint Framework - Developer Preview
SharePoint Framework - Developer Preview
 
Salesforce Lightning workshop Hartford - 12 March
Salesforce Lightning workshop Hartford - 12 MarchSalesforce Lightning workshop Hartford - 12 March
Salesforce Lightning workshop Hartford - 12 March
 
Introducing Office Web Apps as a Tool for Developing Content Rich Applications
Introducing Office Web Apps as a Tool for Developing Content Rich ApplicationsIntroducing Office Web Apps as a Tool for Developing Content Rich Applications
Introducing Office Web Apps as a Tool for Developing Content Rich Applications
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
Developing Sandbox Solutions
Developing Sandbox SolutionsDeveloping Sandbox Solutions
Developing Sandbox Solutions
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017
 
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
O365Con18 - Hybrid SharePoint Deep Dive - Thomas VochtenO365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
 
JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint Developers
 
MOKA .Net Study Week 02
MOKA .Net Study Week 02MOKA .Net Study Week 02
MOKA .Net Study Week 02
 
Sitecore and Responsive Web Design
Sitecore and Responsive Web Design Sitecore and Responsive Web Design
Sitecore and Responsive Web Design
 
Fun with Social, Windows 8 and Javascript
Fun with Social, Windows 8 and JavascriptFun with Social, Windows 8 and Javascript
Fun with Social, Windows 8 and Javascript
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
 

Similar to Sitecore MVC: What it is and why it's important

Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0
Mayank Srivastava
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
MaslowB
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVCIntroduction to ASP.Net MVC
Introduction to ASP.Net MVC
Sagar Kamate
 

Similar to Sitecore MVC: What it is and why it's important (20)

Fast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVCFast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVC
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
 
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
 
Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
 
Session 46 - Spring - Part 4 - Spring MVC
Session 46 - Spring - Part 4 - Spring MVCSession 46 - Spring - Part 4 - Spring MVC
Session 46 - Spring - Part 4 - Spring MVC
 
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORKSpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVCIntroduction to ASP.Net MVC
Introduction to ASP.Net MVC
 
Mvc Brief Overview
Mvc Brief OverviewMvc Brief Overview
Mvc Brief Overview
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
ASP.NET MVC overview
ASP.NET MVC overviewASP.NET MVC overview
ASP.NET MVC overview
 

More from nonlinear creations

Sitecore 7: A developers quest to mastering unit testing
Sitecore 7: A developers quest to mastering unit testingSitecore 7: A developers quest to mastering unit testing
Sitecore 7: A developers quest to mastering unit testing
nonlinear creations
 

More from nonlinear creations (17)

Sitecore User Group: Session State and Sitecore xDB
Sitecore User Group: Session State and Sitecore xDB Sitecore User Group: Session State and Sitecore xDB
Sitecore User Group: Session State and Sitecore xDB
 
Sitecore on Azure
Sitecore on AzureSitecore on Azure
Sitecore on Azure
 
Unofficial Sitecore Training - Data enrichment and personalization
Unofficial Sitecore Training - Data enrichment and personalizationUnofficial Sitecore Training - Data enrichment and personalization
Unofficial Sitecore Training - Data enrichment and personalization
 
The SickKids Foundation on enabling a digital CXM 'hub' with Sitecore
The SickKids Foundation on enabling a digital CXM 'hub' with SitecoreThe SickKids Foundation on enabling a digital CXM 'hub' with Sitecore
The SickKids Foundation on enabling a digital CXM 'hub' with Sitecore
 
Intranet trends to watch
Intranet trends to watchIntranet trends to watch
Intranet trends to watch
 
Design Credibility: No one trusts an ugly website
Design Credibility: No one trusts an ugly websiteDesign Credibility: No one trusts an ugly website
Design Credibility: No one trusts an ugly website
 
National Wildlife Federation- OMS- Dreamcore 2011
National Wildlife Federation- OMS- Dreamcore 2011National Wildlife Federation- OMS- Dreamcore 2011
National Wildlife Federation- OMS- Dreamcore 2011
 
Spiral into control with Knowledge Management
Spiral into control with Knowledge ManagementSpiral into control with Knowledge Management
Spiral into control with Knowledge Management
 
Icebergs
IcebergsIcebergs
Icebergs
 
8 tips for successful change management
8 tips for successful change management8 tips for successful change management
8 tips for successful change management
 
Cms project-failing-the-software-or-the-partner
Cms project-failing-the-software-or-the-partnerCms project-failing-the-software-or-the-partner
Cms project-failing-the-software-or-the-partner
 
Understanding cloud platform services
Understanding cloud platform servicesUnderstanding cloud platform services
Understanding cloud platform services
 
ALM 101: An introduction to application lifecycle management
ALM 101: An introduction to application lifecycle managementALM 101: An introduction to application lifecycle management
ALM 101: An introduction to application lifecycle management
 
Understanding web engagement management (WEM) and your social media presence
Understanding web engagement management (WEM) and your social media presenceUnderstanding web engagement management (WEM) and your social media presence
Understanding web engagement management (WEM) and your social media presence
 
Sitecore: Understanding your visitors and user personas
Sitecore: Understanding your visitors and user personas Sitecore: Understanding your visitors and user personas
Sitecore: Understanding your visitors and user personas
 
Social intranets: 10 ways to drive adoption
Social intranets: 10 ways to drive adoptionSocial intranets: 10 ways to drive adoption
Social intranets: 10 ways to drive adoption
 
Sitecore 7: A developers quest to mastering unit testing
Sitecore 7: A developers quest to mastering unit testingSitecore 7: A developers quest to mastering unit testing
Sitecore 7: A developers quest to mastering unit testing
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Sitecore MVC: What it is and why it's important

  • 1. What is Sitecore MVC? Out on the razor’s edge Prepared by: Jason St-Cyr and Nick Allen
  • 2. What is Sitecore MVC? • MVC as you may know it • Sitecore MVC • Why bother moving to Sitecore MVC? Resources
  • 3.
  • 4. 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 configuration Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 4
  • 5. MVC as you know it: Route registration public 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 parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } protected void Application_Start() { RegisterRoutes(RouteTable.Routes); } }
  • 6. MVC as you know it: Controllers public class CustomerController : Controller { // // POST: /Customer/Edit/5 [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here return RedirectToAction("Index"); } catch { return View(); } } }
  • 7. 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 and presentation details, just like with Web Forms - Individual components are defined as Controller Renderings or View Renderings - Instead of ‘controller-per-page’, Sitecore uses ‘controller-per-rendering’ - Sitecore will run in “MVC mode” if: a) An MVC route is matched b) Item layout is an MVC view Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 7
  • 8. Sitecore MVC: Controller vs. View Renderings • Controller Rendering • Executes Controller you build • Can specify relative or fully qualified class for controller • Controller logic builds model and determines views • Controller is similar to code-behind of an ASCX • View Rendering • Sitecore becomes the Controller • Directly binds to an associated .cshtml file • Requires a model item, which binds directly to rendering model class • Useful for ‘presentation-only’ renderings (e.g. layout renderings) Toronto | Ottawa | New York | Calgary | São Paulo | Florianópolis 8
  • 9. 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 | São Paulo | Florianópolis 9
  • 11. Sitecore Community Docs • http://sitecore-community. github.io/docs/documentation/Sitecore%20MV C/index.html • Contains links to online content submitted by the Sitecore community. • 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 | São Paulo | Florianópolis 11
  • 12. 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
  • 13. Jason St-Cyr  Solution Architect and Sitecore MVP, nonlinear digital Lessons Learned  Background in .NET software development and Application Lifecycle Management  Contact me: jst-cyr@nonlinear.ca  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
  • 14. Nick Allen  Solution Architect and Sitecore MVP, nonlinear digital Lessons Learned  Background in .NET software development  Contact me: nallen@nonlinear.ca  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