SlideShare a Scribd company logo
Sitecore MVC
What we will see today? Areyouexcited?
• What is Sitecore MVC
• How does it differ from regular .NET MVC?
• Using Web forms and MVC within one solution Sitecore
• Should we use Sitecore MVC?
• Installing and Configuring Sitecore MVC
• Renderings
• @Html.Sitecore() Helper and creating custom Sitecore helper
• Using your own model instead of RenderingModel
What is Sitecore MVC?
• A View, It is the component that displays the application's user interface (UI) (all of the things
the user can see and respond to on the screen, such as buttons, display boxes, and so forth).
• A Model, which represents the underlying, logical structure of data in a software application
and the high-level class associated with it at data domain. This object model does not contain
any information about the user interface and the implementation.
• A Controller, which represents the underlying, logical structure of data in a software application
and the high-level class associated with it. This object model does not contain any information
about the user interface.
A traditional ASP.NET MVC request
Using Web forms and MVC within one
solution Sitecore
• Yes. We can use both the approach, a traditional web form and even a MVC in a single solution
of Sitecore project.
• I know you guys will have question,
How it will differentiate a traditional Web form request and MVC request in Sitecore?
Sitecore MVC request
Should we use Sitecore MVC?
• Yes
• No
• Both are true answers.
We should ask question instead,
When we should use Sitecore MVC?
MVC Web Forms
• Shorter page lifecycle, better performance • Extra built-in security
• Steep learning curve for web forms developers and junior developers • Faster to build, less classes
• Easy to add DI and more flexible unit testing • Easier to understand for less seasoned .NET developers
* Forces a convention and cleaner coding • Larger knowledge base/ documentation and more tutorials available
• RAZOR view engine is very convenient for front-end integration. • More developers out there with experience in coding with web forms & Sitecore
• Will be supported by Sitecore going forward (we have confirmed this from the
very top)
• Will be supported by Sitecore going forward
• Helps pull new talent, newer framework (with Sitecore) • Will not be made redundant by MVC any time soon
• We would advice that you have a fairly senior .NET development team (That we
have, without any doubt).
• More Sitecore partners are familiar with web forms, so more support available if
short-staffed or something goes wrong
• There are some very large Sitecore clients implementing solutions with MVC,
some of which are already live.
• Tried and tested, most existing Sitecore solutions are built with web forms.
• Very stable, MVC has been around with .NET for a long time, there was not a lot
of core code Sitecore needed to change to support MVC
• Very stable
• Good de-coupling from HTML, no need to worry about automatic ID's generated
by web-forms controls, resulting in cleaner HTML output.
• Fastest approach to get a clean application live for a company with predominantly
web forms experience.
Renderings
Common Renderings
• Method Rendering
• Url Rendering
• Item rendering
• Webcontrol
• Xsl Rendering
MVC specific renderings
• View renderings
• Controller renderings
View Rendering
A view rendering consists of a view that takes a RenderingModel by default. The model is
assembled by the Sitecore MVC pipeline, and you can create your own, custom models. Because
the pipeline expects an Initialize() method on your model, you can either inherit from
RenderingModel or implement IRenderingModel.
To post a view rendering, specify the controller and action that you want to post to on the
component’s definition item.
Advantages
• They are simple to use – especially if you do not use a custom model. Most of the time, you only
want to display some content from the context or data source item without requiring any
business logic – a simple ‘page’ will often consist of a title and some text, which you can do very
easily with Sitecore’s RenderingModel and the @Html.Sitecore() helper. There isn’t much to unit
test here (you can certainly do web tests), and creating a controller action seems extraneous.
• When you post a form from a view rendering, it will only post the action you have specified – after which you
can redirect to another page or trigger the Sitecore rendering pipeline. This is not the case with controller
renderings, which make posting forms a bit more difficult.
Disadvantages
• If you need to do any business logic when retrieving your model, you will want to do that in a separate layer.
However, because you do not have access to a controller, the only place you can do this logic is in the
Initialize() method of a custom model – and putting business logic in the model itself is not ideal.
• It’s just not very ASP.NET MVC. Developers are used to having a controller and an action, and view renderings
do not work like that. However, you must keep in mind that Sitecore MVC is an implementation of ASP.NET
MVC that needs to support the same features as its Web Forms counterpart. The modular nature of a Sitecore
page introduces challenges.
Controller Rendering
Rather than specifying a view, the component definition item for a controller rendering specifies
a controller name and an action name. When the rendering is added to a placeholder, this
action is executed and the view is returned.
Advantages
• They look ASP.NET MVC. You can use dependency injection and common patterns (like the
repository pattern) as you normally would, and create your own actions.
• Keeps your business logic separate from your model; you can create plain POCO classes that are
hydrated by a business logic layer.
Disadvantages
• Although they look ASP.NET MVC, they are still renderings and will not behave exactly as a controller
action might in a standard ASP.NET MVC application. This is particularly evident when you try to have
more than one post on the page, or attempt to RedirectToAction.
• They are executed after the main view has already been rendered, which results in some
unexpected behavior – again, this might cause some strange behavior when you try to post a form,
and with TempData (if you use that).
• In some instances, a controller rendering is a lot of unnecessary work
@Html.Sitecore() Helper
References
• http://www.hhogdev.com/blog/2012/august/sitecore-mvc-prototype-part1.aspx part - 1
• http://www.hhogdev.com/blog/2012/august/~/link.aspx?_id=F97F95290694409A99655C2F3D90021D&
_z=z part – 2
• http://www.hhogdev.com/blog/2012/august/~/~/link.aspx?_id=B8303C775D554C2A82A337FD4AD48B
E1&_z=z part – 3
• http://mhwelander.net/2014/05/28/posting-forms-in-sitecore-mvc-part-1-view-renderings/
• http://mhwelander.net/2014/05/30/posting-forms-in-sitecore-mvc-part-2-controller-renderings/
• http://mhwelander.net/2014/06/13/view-renderings-vs-controller-renderings/
• Video Tutorials:
• https://www.youtube.com/watch?v=i3Mwcphtz4w part - 1
• https://www.youtube.com/watch?v=dW_rQp9bMmE part – 2
Thank You
CREATED BY PRATIK SATIKUNVAR

More Related Content

PPTX
24 Sitecore Tips that Every Sitecore Architect Needs to Know
PPTX
Animation and Video
PDF
Including Everyone: Web Accessibility 101
PDF
Best PHP Frameworks
PPTX
Web Development
PDF
How To be a Backend developer
PDF
Integrating React.js Into a PHP Application: Dutch PHP 2019
PDF
Developing Apps With React Native
24 Sitecore Tips that Every Sitecore Architect Needs to Know
Animation and Video
Including Everyone: Web Accessibility 101
Best PHP Frameworks
Web Development
How To be a Backend developer
Integrating React.js Into a PHP Application: Dutch PHP 2019
Developing Apps With React Native

What's hot (20)

PDF
Flutter vs React Native | Edureka
PPTX
DeepFake: Trick or Treat
PPTX
Flutter presentation.pptx
PPTX
ASP.NET MVC Presentation
PDF
Website Development Process
PPTX
ASP.NET Core MVC + Web API with Overview
PDF
Intro To React Native
PPT
USER INTERFACE DESIGN PPT
PDF
Continuous Integration (CI) - An effective development practice
PDF
COMP 4010 Lecture3: Human Perception
PDF
Google flutter the easy and practical way
PPTX
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
PPTX
Different types of mobile apps
PPTX
Flutter Intro
PPT
Android Application Development Using Java
PPTX
Autodesk maya
PPT
Augmented Reality And Fashion
PPTX
PDF
Flutter beyond hello world
PPT
Visual programming lecture
Flutter vs React Native | Edureka
DeepFake: Trick or Treat
Flutter presentation.pptx
ASP.NET MVC Presentation
Website Development Process
ASP.NET Core MVC + Web API with Overview
Intro To React Native
USER INTERFACE DESIGN PPT
Continuous Integration (CI) - An effective development practice
COMP 4010 Lecture3: Human Perception
Google flutter the easy and practical way
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Different types of mobile apps
Flutter Intro
Android Application Development Using Java
Autodesk maya
Augmented Reality And Fashion
Flutter beyond hello world
Visual programming lecture
Ad

Viewers also liked (10)

PPTX
Understanding the Sitecore Architecture
PPTX
Sitecore xDB - Architecture and Configuration
PPTX
Sitecore MVC: What it is and why it's important
PPTX
Sitecore MVC: Converting Web Forms sublayouts
PDF
How to Easily Create a Page in Sitecore
PPTX
The Sitecore Marketing Technology Ecosystem
PDF
Know every customer, own every experience, david sigerson, senior business op...
 
PDF
Sitecore: Understanding your visitors and user personas
PPTX
Sitecore xPlatform - Introduction
PPTX
Introducing Sitecore - The Experience Platform
Understanding the Sitecore Architecture
Sitecore xDB - Architecture and Configuration
Sitecore MVC: What it is and why it's important
Sitecore MVC: Converting Web Forms sublayouts
How to Easily Create a Page in Sitecore
The Sitecore Marketing Technology Ecosystem
Know every customer, own every experience, david sigerson, senior business op...
 
Sitecore: Understanding your visitors and user personas
Sitecore xPlatform - Introduction
Introducing Sitecore - The Experience Platform
Ad

Similar to Sitecore mvc (20)

PDF
Sitecore MVC Advanced
PPTX
Sitecore MVC (London User Group, April 29th 2014)
PDF
Introduction to ASP.NET MVC
PPTX
Sitecore MVC (User Group Conference, May 23rd 2014)
PPTX
Mvc presentation
PPTX
Getting started with MVC 5 and Visual Studio 2013
PDF
Murach: An introduction to web programming with ASP.NET Core MVC
PPT
MVC Architecture in ASP.Net By Nyros Developer
PPTX
PPTX
Hanselman lipton asp_connections_ams304_mvc
PPTX
ASP .NET MVC Introduction & Guidelines
PDF
Asp.net difference faqs- 8
PPTX
2011 NetUG HH: ASP.NET MVC & HTML 5
PPTX
Asp.net mvc 5 course module 1 overview
PPTX
Asp.net With mvc handson
PPTX
PPTX
Which is better asp.net mvc vs asp.net
PPTX
MVC Framework
PPTX
Creating Tomorrow’s Web Applications Using Today’s Technologies
PPT
Introduction to ASP.NET MVC 1.0
Sitecore MVC Advanced
Sitecore MVC (London User Group, April 29th 2014)
Introduction to ASP.NET MVC
Sitecore MVC (User Group Conference, May 23rd 2014)
Mvc presentation
Getting started with MVC 5 and Visual Studio 2013
Murach: An introduction to web programming with ASP.NET Core MVC
MVC Architecture in ASP.Net By Nyros Developer
Hanselman lipton asp_connections_ams304_mvc
ASP .NET MVC Introduction & Guidelines
Asp.net difference faqs- 8
2011 NetUG HH: ASP.NET MVC & HTML 5
Asp.net mvc 5 course module 1 overview
Asp.net With mvc handson
Which is better asp.net mvc vs asp.net
MVC Framework
Creating Tomorrow’s Web Applications Using Today’s Technologies
Introduction to ASP.NET MVC 1.0

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
cuic standard and advanced reporting.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
The Rise and Fall of 3GPP – Time for a Sabbatical?
cuic standard and advanced reporting.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Sitecore mvc

  • 2. What we will see today? Areyouexcited? • What is Sitecore MVC • How does it differ from regular .NET MVC? • Using Web forms and MVC within one solution Sitecore • Should we use Sitecore MVC? • Installing and Configuring Sitecore MVC • Renderings • @Html.Sitecore() Helper and creating custom Sitecore helper • Using your own model instead of RenderingModel
  • 3. What is Sitecore MVC? • A View, It is the component that displays the application's user interface (UI) (all of the things the user can see and respond to on the screen, such as buttons, display boxes, and so forth). • A Model, which represents the underlying, logical structure of data in a software application and the high-level class associated with it at data domain. This object model does not contain any information about the user interface and the implementation. • A Controller, which represents the underlying, logical structure of data in a software application and the high-level class associated with it. This object model does not contain any information about the user interface.
  • 4. A traditional ASP.NET MVC request
  • 5. Using Web forms and MVC within one solution Sitecore • Yes. We can use both the approach, a traditional web form and even a MVC in a single solution of Sitecore project. • I know you guys will have question, How it will differentiate a traditional Web form request and MVC request in Sitecore?
  • 7. Should we use Sitecore MVC? • Yes • No • Both are true answers. We should ask question instead, When we should use Sitecore MVC?
  • 8. MVC Web Forms • Shorter page lifecycle, better performance • Extra built-in security • Steep learning curve for web forms developers and junior developers • Faster to build, less classes • Easy to add DI and more flexible unit testing • Easier to understand for less seasoned .NET developers * Forces a convention and cleaner coding • Larger knowledge base/ documentation and more tutorials available • RAZOR view engine is very convenient for front-end integration. • More developers out there with experience in coding with web forms & Sitecore • Will be supported by Sitecore going forward (we have confirmed this from the very top) • Will be supported by Sitecore going forward • Helps pull new talent, newer framework (with Sitecore) • Will not be made redundant by MVC any time soon • We would advice that you have a fairly senior .NET development team (That we have, without any doubt). • More Sitecore partners are familiar with web forms, so more support available if short-staffed or something goes wrong • There are some very large Sitecore clients implementing solutions with MVC, some of which are already live. • Tried and tested, most existing Sitecore solutions are built with web forms. • Very stable, MVC has been around with .NET for a long time, there was not a lot of core code Sitecore needed to change to support MVC • Very stable • Good de-coupling from HTML, no need to worry about automatic ID's generated by web-forms controls, resulting in cleaner HTML output. • Fastest approach to get a clean application live for a company with predominantly web forms experience.
  • 9. Renderings Common Renderings • Method Rendering • Url Rendering • Item rendering • Webcontrol • Xsl Rendering MVC specific renderings • View renderings • Controller renderings
  • 10. View Rendering A view rendering consists of a view that takes a RenderingModel by default. The model is assembled by the Sitecore MVC pipeline, and you can create your own, custom models. Because the pipeline expects an Initialize() method on your model, you can either inherit from RenderingModel or implement IRenderingModel. To post a view rendering, specify the controller and action that you want to post to on the component’s definition item. Advantages • They are simple to use – especially if you do not use a custom model. Most of the time, you only want to display some content from the context or data source item without requiring any business logic – a simple ‘page’ will often consist of a title and some text, which you can do very easily with Sitecore’s RenderingModel and the @Html.Sitecore() helper. There isn’t much to unit test here (you can certainly do web tests), and creating a controller action seems extraneous.
  • 11. • When you post a form from a view rendering, it will only post the action you have specified – after which you can redirect to another page or trigger the Sitecore rendering pipeline. This is not the case with controller renderings, which make posting forms a bit more difficult. Disadvantages • If you need to do any business logic when retrieving your model, you will want to do that in a separate layer. However, because you do not have access to a controller, the only place you can do this logic is in the Initialize() method of a custom model – and putting business logic in the model itself is not ideal. • It’s just not very ASP.NET MVC. Developers are used to having a controller and an action, and view renderings do not work like that. However, you must keep in mind that Sitecore MVC is an implementation of ASP.NET MVC that needs to support the same features as its Web Forms counterpart. The modular nature of a Sitecore page introduces challenges.
  • 12. Controller Rendering Rather than specifying a view, the component definition item for a controller rendering specifies a controller name and an action name. When the rendering is added to a placeholder, this action is executed and the view is returned. Advantages • They look ASP.NET MVC. You can use dependency injection and common patterns (like the repository pattern) as you normally would, and create your own actions. • Keeps your business logic separate from your model; you can create plain POCO classes that are hydrated by a business logic layer.
  • 13. Disadvantages • Although they look ASP.NET MVC, they are still renderings and will not behave exactly as a controller action might in a standard ASP.NET MVC application. This is particularly evident when you try to have more than one post on the page, or attempt to RedirectToAction. • They are executed after the main view has already been rendered, which results in some unexpected behavior – again, this might cause some strange behavior when you try to post a form, and with TempData (if you use that). • In some instances, a controller rendering is a lot of unnecessary work
  • 15. References • http://www.hhogdev.com/blog/2012/august/sitecore-mvc-prototype-part1.aspx part - 1 • http://www.hhogdev.com/blog/2012/august/~/link.aspx?_id=F97F95290694409A99655C2F3D90021D& _z=z part – 2 • http://www.hhogdev.com/blog/2012/august/~/~/link.aspx?_id=B8303C775D554C2A82A337FD4AD48B E1&_z=z part – 3 • http://mhwelander.net/2014/05/28/posting-forms-in-sitecore-mvc-part-1-view-renderings/ • http://mhwelander.net/2014/05/30/posting-forms-in-sitecore-mvc-part-2-controller-renderings/ • http://mhwelander.net/2014/06/13/view-renderings-vs-controller-renderings/ • Video Tutorials: • https://www.youtube.com/watch?v=i3Mwcphtz4w part - 1 • https://www.youtube.com/watch?v=dW_rQp9bMmE part – 2
  • 16. Thank You CREATED BY PRATIK SATIKUNVAR