SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Sitecore MVC Advanced
Kevin Brechbühl
Unic AG
@aquasonic
Sitecore User Group Conference 2015 1
About
• Senior Sitecore developer & architect @unic
• Sitecore Technology MVP 2015
• Co-founder of @sugch
Sitecore User Group Conference 2015 2
Agenda
• ASP.net MVC vs. Sitecore MVC
• Multiple Forms
• MVC Forms Localization
• MVC Areas
• There is always more...
Sitecore User Group Conference 2015 3
ASP.net MVC vs. Sitecore MVC
Sitecore User Group Conference 2015 4
Traditional ASP.net MVC
Sitecore User Group Conference 2015 5
Traditional ASP.net MVC
Sitecore User Group Conference 2015 6
Sitecore MVC
Sitecore User Group Conference 2015 7
Sitecore MVC
Sitecore User Group Conference 2015 8
Sitecore MVC
Sitecore User Group Conference 2015 9
Sitecore MVC
Sitecore User Group Conference 2015 10
Sitecore MVC
Sitecore User Group Conference 2015 11
ASP.net MVC
• Request correspond to
controller action
• One view with several partial
views
• 1 controller & 1 action
Sitecore MVC
• Request correspond to
Sitecore item
• Views defined in
presentation details
• n controllers & n actions
Sitecore User Group Conference 2015 12
ASP.net MVC vs. Sitecore MVC
Resources
• Comparison from John West
http://bit.ly/SitecoreMvcComparison
• ASP.net MVC Lifecycle
http://bit.ly/MvcLifecycle
• Sitecore MVC Pipelines
http://bit.ly/SitecoreMvcPipelines
Sitecore User Group Conference 2015 13
Multiple Forms
Sitecore User Group Conference 2015 14
ASP.net MVC form posts
• Each form has 2 actions
• Handling GET requests
• Handling POST requests
• Action has ActionMethodSelector
• [HttpGet] or empty
• [HttpPost]
Sitecore User Group Conference 2015 15
ASP.net MVC form posts
Sitecore User Group Conference 2015 16
{ CODE }
Issues with Sitecore?
• Multiple controllers & multiple actions
• Post to same page / url
• Each [HttpPost] action is called
• Each form is validated
• AntiForgeryToken does not work properly
Sitecore User Group Conference 2015 17
Solutions
• Post via Ajax
• Sitecore MVC Form Handler
• Custom ActionMethodSelector
• As close to ASP.net MVC as possible
• None of the described issues
Sitecore User Group Conference 2015 18
Custom ActionMethodSelector
• Adding a hidden field to the form
• Unique Id of the rendering
• Post to same page / url
• Adding the ActionMethodSelector to the action
• Verify the posted rendering id
Sitecore User Group Conference 2015 19
Custom ActionMethodSelector
Sitecore User Group Conference 2015 20
{ CODE }
Resources
• Mine: http://bit.ly/MultipleForms1
• Renoud van Dalen: http://bit.ly/MultipleForms2
Sitecore User Group Conference 2015 21
MVC Forms localization
Sitecore User Group Conference 2015 22
MVC Forms localization
• Ways to translate an ASP.net MVC form
• Use .NET language pack
• Add static textes
• Use .NET resource files
• Localization within Sitecore
• Sitecore dictionaries
Sitecore User Group Conference 2015 23
MVC Forms localization
Sitecore User Group Conference 2015 24
{ CODE }
Translate labels
• Use custom MetaDataProvider
• First create the default metadata for a field
• Type, Format etc.
• Override the DisplayName
Sitecore User Group Conference 2015 25
Translate labels
Sitecore User Group Conference 2015 26
{ CODE }
Translate labels
• Conflicts with WFFM MVC
• Override the WFFM provider
• Register custom provider after WFFM provider
Sitecore User Group Conference 2015 27
Translate validation messages
• Custom DataAnnotationsModelValidator
• Works as an adapter
• Each validator type needs a custom adapter
Sitecore User Group Conference 2015 28
Translate validation messages
Sitecore User Group Conference 2015 29
{ CODE }
Resources
• Sitecore Usergroup Switzerland
• From @studert and me
• http://bit.ly/FormsLocalization
Sitecore User Group Conference 2015 30
MVC Areas
Sitecore User Group Conference 2015 31
Structure of Areas
Sitecore User Group Conference 2015 32
Default
Structure of Areas
Sitecore User Group Conference 2015 33
Default
Area 1
Structure of Areas
Sitecore User Group Conference 2015 34
Default
Area 2
Area 1
Areas what?
• Split models/views/controllers in different areas
• Used with multiple sites/layouts in one Sitecore instance
• No support by Sitecore, because
• No area token in Sitecore default route
• Layout termination over pipelines and presentation details
Sitecore User Group Conference 2015 35
Solutions
• Resolve in mvc.renderRendering pipeline
• Use custom ControllerRunner and Renderer
• Resolve by <site>
Sitecore User Group Conference 2015 36
Resolve in mvc.renderRendering pipeline
• Set RouteData.DataTokens["area"]
• Controller is then resolved in area
• Resolve the area in a custom pipeline
• New fields on folders / renderings
• Resource
• BrainJocks SCORE: http://bit.ly/MvcAreas1
Sitecore User Group Conference 2015 37
Resolve in mvc.renderRendering
Sitecore User Group Conference 2015 38
{ CODE }
Use custom ControllerRunner
• Custom ControllerRunner in mvc.getRenderer pipeline
• Also set RouteData-token
• Resolve area by new «Area Controller Rendering»
• With new AreaControllerRenderer
• Resource
• Christian van de Luitgaarden: http://bit.ly/MvcAreas2
Sitecore User Group Conference 2015 39
Use custom ControllerRunner
Sitecore User Group Conference 2015 40
{ CODE }
Resolve by <site>
• Adding new route per <site>
• Configure with new parameter
• Before the Sitecore default route
• Add RouteData-token and constraint to each route
• Resource
• Chris van de Steeg: http://bit.ly/MvcAreas3
Sitecore User Group Conference 2015 41
Resolve by <site>
Sitecore User Group Conference 2015 42
{ CODE }
But, wait...
Sitecore User Group Conference 2015 43
Sitecore Area support
• Pattern from BrainJocks
• Multiple strategies to resolve the area
• Extensible by developers
Sitecore User Group Conference 2015 44
There is always more...
Sitecore User Group Conference 2015 45
Other resources
• Sample Items in MVC
http://bit.ly/Sample7Mvc & http://bit.ly/Sample8Mvc
• Async Sitecore controllers
http://bit.ly/AsyncControllers
• Using Dependency Injection to determine MVC Models
http://bit.ly/ModelsDI
• BrainJocks SCORE
http://bit.ly/BJScore
Sitecore User Group Conference 2015 46
UserVoice
• Sitecore needs your feedback
• Share and vote your ideas
• Not only for MVC ;-)
• http://bit.ly/MvcUserVoice
Sitecore User Group Conference 2015 47
/me
• Twitter: @aquasonic
• Private Blog: http://ctor.io
• Sitecore Vibes: http://sitecore.unic.com
• Sitecore Usergroup Switzerland: http://sugch.github.io
Sitecore User Group Conference 2015 48
Thank you
Sitecore User Group Conference 2015 49
Thank you
Sitecore User Group Conference 2015 50

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

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
 
Everything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 minEverything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 min
 
Grails At Linked
Grails At LinkedGrails At Linked
Grails At Linked
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practices
 
Understanding SharePoint Framework Extensions
Understanding SharePoint Framework ExtensionsUnderstanding SharePoint Framework Extensions
Understanding SharePoint Framework Extensions
 
Kentico and MVC
Kentico and MVCKentico and MVC
Kentico and MVC
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
SharePoint Framework
SharePoint FrameworkSharePoint Framework
SharePoint Framework
 
Lwc presentation
Lwc presentationLwc presentation
Lwc presentation
 
Developing Sandbox Solutions
Developing Sandbox SolutionsDeveloping Sandbox Solutions
Developing Sandbox Solutions
 
Playing in the Sandbox by Wictor Wilén
Playing in the Sandbox by Wictor WilénPlaying in the Sandbox by Wictor Wilén
Playing in the Sandbox by Wictor Wilén
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Word on the Server
Word on the ServerWord on the Server
Word on the Server
 
Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
An Introduction to the Office 365 Patterns and Practices Project
An Introduction to the Office 365 Patterns and Practices ProjectAn Introduction to the Office 365 Patterns and Practices Project
An Introduction to the Office 365 Patterns and Practices Project
 
Using the Kentico CMS API
Using the Kentico CMS APIUsing the Kentico CMS API
Using the Kentico CMS API
 
Salesforce Lightning Data Service
Salesforce Lightning Data ServiceSalesforce Lightning Data Service
Salesforce Lightning Data Service
 
SharePoint + Silverlight - new BFF's by Wictor Wilén
SharePoint + Silverlight - new BFF's by Wictor WilénSharePoint + Silverlight - new BFF's by Wictor Wilén
SharePoint + Silverlight - new BFF's by Wictor Wilén
 

Destaque

Website personalization: The best way to boost your conversion rates
Website personalization: The best way to boost your conversion ratesWebsite personalization: The best way to boost your conversion rates
Website personalization: The best way to boost your conversion rates
Qubit
 
Real-Time Personalization: Top 5 Use Cases to Boost Conversions
Real-Time Personalization: Top 5 Use Cases to Boost ConversionsReal-Time Personalization: Top 5 Use Cases to Boost Conversions
Real-Time Personalization: Top 5 Use Cases to Boost Conversions
Marketo
 
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
A AOKI
 

Destaque (9)

Introducing Sitecore - The Experience Platform
Introducing Sitecore - The Experience PlatformIntroducing Sitecore - The Experience Platform
Introducing Sitecore - The Experience Platform
 
Introduction To Umbraco
Introduction To UmbracoIntroduction To Umbraco
Introduction To Umbraco
 
Era of Engagement Marketing / Marketo
Era of Engagement Marketing / MarketoEra of Engagement Marketing / Marketo
Era of Engagement Marketing / Marketo
 
Marketo Real Time Web Personalisation
Marketo Real Time Web Personalisation  Marketo Real Time Web Personalisation
Marketo Real Time Web Personalisation
 
Why Web Personalisation - Web personalisation workshop tania
Why Web Personalisation  - Web personalisation workshop   taniaWhy Web Personalisation  - Web personalisation workshop   tania
Why Web Personalisation - Web personalisation workshop tania
 
Website personalization: The best way to boost your conversion rates
Website personalization: The best way to boost your conversion ratesWebsite personalization: The best way to boost your conversion rates
Website personalization: The best way to boost your conversion rates
 
Real-Time Personalization: How to Optimize Your Website and Boost Conversions
Real-Time Personalization: How to Optimize Your Website and Boost ConversionsReal-Time Personalization: How to Optimize Your Website and Boost Conversions
Real-Time Personalization: How to Optimize Your Website and Boost Conversions
 
Real-Time Personalization: Top 5 Use Cases to Boost Conversions
Real-Time Personalization: Top 5 Use Cases to Boost ConversionsReal-Time Personalization: Top 5 Use Cases to Boost Conversions
Real-Time Personalization: Top 5 Use Cases to Boost Conversions
 
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
「実践ドメイン駆動設計」社内読書会まとめ ~IDDD本難民に捧げる1章から7章~
 

Semelhante a Sitecore MVC Advanced

Water cad v8i user's guide
Water cad v8i user's guideWater cad v8i user's guide
Water cad v8i user's guide
mignan22
 

Semelhante a Sitecore MVC Advanced (20)

SUGCON 2015 Modelling
SUGCON 2015 ModellingSUGCON 2015 Modelling
SUGCON 2015 Modelling
 
Water cad v8i user's guide
Water cad v8i user's guideWater cad v8i user's guide
Water cad v8i user's guide
 
Sitecore - what to look forward to
Sitecore - what to look forward toSitecore - what to look forward to
Sitecore - what to look forward to
 
ASP.NET Core in Action (2018).pdf
ASP.NET Core in Action (2018).pdfASP.NET Core in Action (2018).pdf
ASP.NET Core in Action (2018).pdf
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
 
Testing microservices with docker
Testing microservices with dockerTesting microservices with docker
Testing microservices with docker
 
Create A Mapping Web Part
Create A Mapping Web PartCreate A Mapping Web Part
Create A Mapping Web Part
 
Sitecore MVC Forms Localization
Sitecore MVC Forms LocalizationSitecore MVC Forms Localization
Sitecore MVC Forms Localization
 
New SharePoint Features in Visual Studio 2012!
New SharePoint Features in Visual Studio 2012!New SharePoint Features in Visual Studio 2012!
New SharePoint Features in Visual Studio 2012!
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Debugging Integration Flows
Debugging Integration FlowsDebugging Integration Flows
Debugging Integration Flows
 
Making ultra fast ultra scalable solutions with sitecore 8
Making ultra fast ultra scalable solutions with sitecore 8Making ultra fast ultra scalable solutions with sitecore 8
Making ultra fast ultra scalable solutions with sitecore 8
 
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET CoreTarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013
 
Scribe online 03 scribe online cdk and api overview
Scribe online 03   scribe online cdk and api overviewScribe online 03   scribe online cdk and api overview
Scribe online 03 scribe online cdk and api overview
 
Microsoft Certified Solution Developer.pptx
Microsoft Certified Solution Developer.pptxMicrosoft Certified Solution Developer.pptx
Microsoft Certified Solution Developer.pptx
 
ms_project_ppt
ms_project_pptms_project_ppt
ms_project_ppt
 

Último

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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Sitecore MVC Advanced