This document summarizes a presentation on advanced Sitecore MVC techniques. The presentation covers the differences between ASP.NET MVC and Sitecore MVC, techniques for handling multiple forms in Sitecore MVC, localization of MVC forms, and using MVC areas in Sitecore. The presentation provides code examples and additional resources for further reading on each topic.
Sitecore is making a move: the shift from Sitecore's web forms to Sitecore MVC has been a gradual one, but it's ramping up quickly. Stay in the know with this primer on what it is and why it's important
Sitecore MVC
A basic guide for using sitecore MVC. difference between Sitecore MVC and Asp.Net MVC, Difference between Sitecore with Webform and MVC. and different rendering methods specific to Sitecore MVC.
This document provides an introduction and overview of ASP.NET MVC architecture. It compares MVC to traditional ASP.NET web forms, describing advantages of MVC such as separation of concerns and better support for test-driven development. It outlines the core MVC components - Model, View, Controller - and how they interact. It also covers routing, passing data between controllers and views, form processing, unit testing, and includes examples of popular MVC sites.
Introducing ASP.NET MVC, which follows an MVC pattern to separate concerns into models, views, and controllers. It aims to address disadvantages of ASP.NET like increasing postbacks and view state as functionality increases. The architecture uses models to pass data between controllers and views, views generate HTML, and controllers handle requests and call views. It establishes standard directories, file naming, and handles the page lifecycle through routing.
The document provides information on ASP.NET MVC, including:
- ASP.NET MVC is a framework for building web apps in .NET using C# or VB.NET that follows the MVC pattern.
- MVC stands for Model-View-Controller, with models containing data, views presenting user interfaces, and controllers coordinating data retrieval and user input.
- ASP.NET MVC provides separation of concerns, testability, and more control over HTML compared to ASP.NET Web Forms.
This document outlines the modules and content covered in an ASP.NET MVC 5 course. The 10 modules cover an overview of MVC, models, controllers, views, security, routing, performance, testing, Web API integration. The agenda includes introductions to MVC architecture, comparisons to Web Forms, project structure, configuration, a demo app, best practices, and homework. Real app showcasing and references are also provided.
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
The document provides an overview of ASP.NET MVC, including its core components and how they differ from ASP.NET Web Forms. It discusses Models, Views, Controllers, validation, routing, unit testing, and view engines. Key points covered include MVC separating application logic, control over HTML, testability, and no viewstate or postbacks. Examples are provided for creating controllers and actions, passing data to views, validation, routing, and unit testing.
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the -what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
The document discusses the Model-View-Controller (MVC) design pattern. MVC separates an application's logic into three main components: the model, the view, and the controller. The model manages the application's data and logic, the view displays the data to the user, and the controller interprets user input and updates the model. MVC improves separation of concerns and makes applications more modular, extensible, and testable. It is commonly used for web applications, where the server handles the model and controller logic while the client handles the view.
The document is a presentation on ASP.NET MVC. It provides an overview of ASP.NET MVC, including that it is a new presentation option for ASP.NET that allows for simpler programming, easier testing, and more control over HTML and URLs. It then demonstrates building a simple ASP.NET MVC application and unit testing controllers. It concludes by discussing factors to consider when choosing between ASP.NET WebForms and MVC.
1. The organization decided to adapt their approach to using ASPX pages as a façade to facilitate calls to MVC controller actions, while still enabling the ongoing use of web parts.
2. This allowed them to attract new developer talent by giving developers complete control over markup and separating layers for easier unit testing.
3. The benefits of this approach included cleaner semantic markup, better performing websites, easier maintenance and fewer bugs.
The document discusses the Model-View-Controller (MVC) architectural pattern used in ASP.NET applications. It describes the three main components - the model, which manages the application's data logic; the view, which displays the user interface; and the controller, which allows manipulation of the view. It provides an overview of how these components are implemented in ASP.NET MVC and the advantages it provides such as testability and separation of concerns. Potential problems discussed include difficulty testing GUI code.
This document provides an overview of ASP.net MVC, including what MVC is, how ASP.net MVC request execution works, details on controllers, routing, application development, differences from web forms, and when to use MVC. It describes MVC as separating applications into models, views, and controllers, and how ASP.net MVC implements the MVC pattern with controllers handling user input and selecting views. Request processing and controller lifecycles are also summarized at a high level.
MVC is a framework that separates an application into three main components: the model, the view, and the controller. The model manages the application's data logic, the view displays the user interface, and the controller handles input and converts it to commands for the model and view. MVC frameworks aim to create loosely coupled and testable web applications and help organize complex projects. ASP.NET MVC was developed by Microsoft as an alternative to Web Forms that embraces the MVC pattern for building dynamic websites using the .NET Framework.
The document provides an overview of ASP.NET MVC, including its architecture, advantages, folder structure, core components like controllers, views and action methods. It describes Model-View-Controller pattern, how controllers handle requests and return views with model data. It also compares ASP.NET MVC to Web Forms and lists some key selector attributes.
Flux is an architecture for building JavaScript applications that promotes unidirectional data flow. The key elements of Flux are the Dispatcher, Stores, and Views. The Dispatcher centralizes the flow of data and dispatches actions to the Stores. Stores contain application state and logic. Views are React components that subscribe to Stores and listen for changes to re-render. Actions define activities and are dispatched by action creators through the Dispatcher to the Stores to update state.
VIPER is an iOS app architecture that separates an app into five components: Views, Interactors, Presenters, Entities, and Routers. This improves upon massive View Controllers by dividing responsibilities between layers. The View layer handles display, the Interactor handles business logic, the Presenter links Views and Interactors, Entities manage data, and the Router manages navigation. A sample journal app is described to demonstrate how VIPER would structure its components.
This contains about
- what is MVC?
- Why people are preferring MVC Application
- Tools and Softwares needs to create MVC Web application
- Differences between ASP.NET and ASP.NET MVC
- Technologies used to create MVC Application
The document provides an introduction to ASP.NET MVC, including definitions of MVC and its components. It discusses the pros and cons of traditional ASP.NET WebForms compared to MVC. Key aspects of MVC like models, views, controllers, routing and HTML helpers are described at a high level. Popular MVC frameworks for different programming languages are also listed.
What can you do with the Kentico API? With over 200 ready to use web parts and a detailed API at your disposal the possibilities are endless. Event handlers, custom providers, customized data structures; programmatically create documents – to name a few. In this session we will explore ways that you can use this API to extend your CMS applications.
The co-speaker for this session is Bryan Soltis, Senior Software Engineer from Bit-Wizards Custom Software Solutions, Inc.
The document discusses design patterns and architectural patterns, specifically focusing on the model-view-controller (MVC) pattern. It provides an overview of MVC, explaining the model, view, and controller components. It then describes how MVC is implemented in ASP.NET MVC, including the request flow and separation of concerns. Some key benefits of ASP.NET MVC like clean URLs, testability, and extensibility are also summarized.
This document discusses ASP.NET MVC, including its components (Model, View, Controller), advantages like separation of concerns and test-driven development, and lifecycle of processing requests and responses. The Model represents application logic, the Controller handles user input, and the View is the visual representation. Data can be passed between these components using ViewData, ViewBag, and TempData. ASP.NET MVC allows full control of HTML, CSS, and JavaScript and provides a cleaner architecture than Web Forms. Any MVC application handles requests by creating a request object and sending a response.
Using a model view-view model architecture for iOS appsallanh0526
The document discusses using a Model-View-ViewModel (MVVM) architecture for iOS apps. MVVM addresses issues with Massive View Controllers in Model-View-Controller (MVC) by separating business logic, state, and data handling from the view controller and putting it into a view model. The view controller is only responsible for displaying the UI and handling user interactions, while the view model handles business logic and data. Data managers are used to retrieve and handle data from a model separately from the view model and view controller. An example implementation demonstrates how to initialize view models, retrieve and display data, and pass data between view controllers using view models.
This document summarizes key aspects of ASP.NET MVC including controllers, actions, returning different result types from actions, passing data to views, using filters, and more. Controllers are responsible for controlling application flow and exposing public methods as actions. Actions can return various result types including ViewResult, RedirectResult, ContentResult, and JsonResult. Data can be passed to views from controllers using ViewData, ViewBag, TempData, and strongly typed models. Filters provide a way to inject extra behaviors into controllers and actions, and common filter types include AuthorizeFilter, HandleErrorFilter, and OutputCacheFilter.
This document outlines the modules and content covered in an ASP.NET MVC 5 course. The 10 modules cover an overview of MVC, models, controllers, views, security, routing, performance, testing, Web API integration. The agenda includes introductions to MVC architecture, comparisons to Web Forms, project structure, configuration, a demo app, best practices, and homework. Real app showcasing and references are also provided.
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
The document provides an overview of ASP.NET MVC, including its core components and how they differ from ASP.NET Web Forms. It discusses Models, Views, Controllers, validation, routing, unit testing, and view engines. Key points covered include MVC separating application logic, control over HTML, testability, and no viewstate or postbacks. Examples are provided for creating controllers and actions, passing data to views, validation, routing, and unit testing.
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the -what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
The document discusses the Model-View-Controller (MVC) design pattern. MVC separates an application's logic into three main components: the model, the view, and the controller. The model manages the application's data and logic, the view displays the data to the user, and the controller interprets user input and updates the model. MVC improves separation of concerns and makes applications more modular, extensible, and testable. It is commonly used for web applications, where the server handles the model and controller logic while the client handles the view.
The document is a presentation on ASP.NET MVC. It provides an overview of ASP.NET MVC, including that it is a new presentation option for ASP.NET that allows for simpler programming, easier testing, and more control over HTML and URLs. It then demonstrates building a simple ASP.NET MVC application and unit testing controllers. It concludes by discussing factors to consider when choosing between ASP.NET WebForms and MVC.
1. The organization decided to adapt their approach to using ASPX pages as a façade to facilitate calls to MVC controller actions, while still enabling the ongoing use of web parts.
2. This allowed them to attract new developer talent by giving developers complete control over markup and separating layers for easier unit testing.
3. The benefits of this approach included cleaner semantic markup, better performing websites, easier maintenance and fewer bugs.
The document discusses the Model-View-Controller (MVC) architectural pattern used in ASP.NET applications. It describes the three main components - the model, which manages the application's data logic; the view, which displays the user interface; and the controller, which allows manipulation of the view. It provides an overview of how these components are implemented in ASP.NET MVC and the advantages it provides such as testability and separation of concerns. Potential problems discussed include difficulty testing GUI code.
This document provides an overview of ASP.net MVC, including what MVC is, how ASP.net MVC request execution works, details on controllers, routing, application development, differences from web forms, and when to use MVC. It describes MVC as separating applications into models, views, and controllers, and how ASP.net MVC implements the MVC pattern with controllers handling user input and selecting views. Request processing and controller lifecycles are also summarized at a high level.
MVC is a framework that separates an application into three main components: the model, the view, and the controller. The model manages the application's data logic, the view displays the user interface, and the controller handles input and converts it to commands for the model and view. MVC frameworks aim to create loosely coupled and testable web applications and help organize complex projects. ASP.NET MVC was developed by Microsoft as an alternative to Web Forms that embraces the MVC pattern for building dynamic websites using the .NET Framework.
The document provides an overview of ASP.NET MVC, including its architecture, advantages, folder structure, core components like controllers, views and action methods. It describes Model-View-Controller pattern, how controllers handle requests and return views with model data. It also compares ASP.NET MVC to Web Forms and lists some key selector attributes.
Flux is an architecture for building JavaScript applications that promotes unidirectional data flow. The key elements of Flux are the Dispatcher, Stores, and Views. The Dispatcher centralizes the flow of data and dispatches actions to the Stores. Stores contain application state and logic. Views are React components that subscribe to Stores and listen for changes to re-render. Actions define activities and are dispatched by action creators through the Dispatcher to the Stores to update state.
VIPER is an iOS app architecture that separates an app into five components: Views, Interactors, Presenters, Entities, and Routers. This improves upon massive View Controllers by dividing responsibilities between layers. The View layer handles display, the Interactor handles business logic, the Presenter links Views and Interactors, Entities manage data, and the Router manages navigation. A sample journal app is described to demonstrate how VIPER would structure its components.
This contains about
- what is MVC?
- Why people are preferring MVC Application
- Tools and Softwares needs to create MVC Web application
- Differences between ASP.NET and ASP.NET MVC
- Technologies used to create MVC Application
The document provides an introduction to ASP.NET MVC, including definitions of MVC and its components. It discusses the pros and cons of traditional ASP.NET WebForms compared to MVC. Key aspects of MVC like models, views, controllers, routing and HTML helpers are described at a high level. Popular MVC frameworks for different programming languages are also listed.
What can you do with the Kentico API? With over 200 ready to use web parts and a detailed API at your disposal the possibilities are endless. Event handlers, custom providers, customized data structures; programmatically create documents – to name a few. In this session we will explore ways that you can use this API to extend your CMS applications.
The co-speaker for this session is Bryan Soltis, Senior Software Engineer from Bit-Wizards Custom Software Solutions, Inc.
The document discusses design patterns and architectural patterns, specifically focusing on the model-view-controller (MVC) pattern. It provides an overview of MVC, explaining the model, view, and controller components. It then describes how MVC is implemented in ASP.NET MVC, including the request flow and separation of concerns. Some key benefits of ASP.NET MVC like clean URLs, testability, and extensibility are also summarized.
This document discusses ASP.NET MVC, including its components (Model, View, Controller), advantages like separation of concerns and test-driven development, and lifecycle of processing requests and responses. The Model represents application logic, the Controller handles user input, and the View is the visual representation. Data can be passed between these components using ViewData, ViewBag, and TempData. ASP.NET MVC allows full control of HTML, CSS, and JavaScript and provides a cleaner architecture than Web Forms. Any MVC application handles requests by creating a request object and sending a response.
Using a model view-view model architecture for iOS appsallanh0526
The document discusses using a Model-View-ViewModel (MVVM) architecture for iOS apps. MVVM addresses issues with Massive View Controllers in Model-View-Controller (MVC) by separating business logic, state, and data handling from the view controller and putting it into a view model. The view controller is only responsible for displaying the UI and handling user interactions, while the view model handles business logic and data. Data managers are used to retrieve and handle data from a model separately from the view model and view controller. An example implementation demonstrates how to initialize view models, retrieve and display data, and pass data between view controllers using view models.
This document summarizes key aspects of ASP.NET MVC including controllers, actions, returning different result types from actions, passing data to views, using filters, and more. Controllers are responsible for controlling application flow and exposing public methods as actions. Actions can return various result types including ViewResult, RedirectResult, ContentResult, and JsonResult. Data can be passed to views from controllers using ViewData, ViewBag, TempData, and strongly typed models. Filters provide a way to inject extra behaviors into controllers and actions, and common filter types include AuthorizeFilter, HandleErrorFilter, and OutputCacheFilter.
The Spring MVC framework uses the model-view-controller (MVC) architecture. It features a DispatcherServlet that handles requests and responses and relies on controllers to process user input and build the model data before passing it to the view for rendering. Configuration involves mapping the DispatcherServlet to URLs in web.xml and defining controllers with annotations and handler methods. Spring Security integrates with Spring MVC to add authentication and authorization for specific URLs specified in the spring-security.xml configuration file.
Building Modern Websites with ASP.NET by Rachel Appel.NET Conf UY
This document provides an overview of building modern websites with ASP.NET MVC, including discussions of models, controllers, views, routing, Entity Framework, and view models. It describes models as the application's data expressed as classes, controllers as handling requests and routing, and views as the UI layer that renders models. It also covers Entity Framework for database mapping, RESTful routing, and using view models to promote separation of concerns.
Mvc interview questions – deep dive jinal desaijinaldesailive
Can you describe ASP.NET MVC Request Life Cycle? 1. Receive request, look up Route object in RouteTable collection and create RouteData object. 2. Create RequestContext instance. 3. Create MvcHandler and pass RequestContext to handler. 4. Identify IControllerFactory from RequestContext. 5. Create instance of class that implements ControllerBase. 6. Call MyController.Execute method. 7. The ControllerActionInvoker determines which action to invoke on the controller and executes the action on the controller, which results in calling the model and returning a view.
This document provides an introduction to ASP.NET MVC, covering the MVC pattern, controllers, actions, routing, views, models, and capturing user input with forms. It discusses key ASP.NET MVC concepts like separation of concerns, the default project structure, and common action filters. The document also provides exercises for readers to create a basic MVC application with a model, controller actions, and views that display and capture data. It concludes by outlining additional topics to be covered in part 2, such as HTML helpers, partial views, and unit testing.
A tutorial about CodeIgniter. It's purpose is to help someone with no prior knowledge of frameworks, to understand it's basic principles and how it works.
A simple presentation to understand what is ASP.net MVC4 and its structure.It covers all important features of MVC4 and razor view engine including screenshots
This document discusses MVC controllers in more detail. It explains that controllers contain action methods that handle requests and return responses. Action methods validate request data, invoke business logic, and select a view or redirect. Parameters can pass data to action methods, which generally return ViewResult or RedirectResult via the IActionResult interface. Controllers follow conventions like ending in "Controller" and inheriting from ControllerBase.
This document discusses creating an MVC application from scratch using LINQ to SQL to perform CRUD operations on a database. It covers:
1. Creating an empty MVC project and adding controllers, views and models
2. Creating a sample database and using LINQ to SQL for communication between the MVC app and database
3. Performing CRUD operations in the MVC app by querying the database and passing data between controllers and views
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
MVC provides a new web project type for ASP.NET that allows for more control over HTML and a more testable framework. It maintains a clean separation of concerns between models, views, and controllers and allows developers to easily extend or replace any component. MVC supports RESTful URLs, integrates well with existing ASP.NET features, and enables test-driven development through mockable abstractions.
This document provides an introduction to Jakarta Struts 1.3, an open source MVC framework for building Java web applications. It discusses the limitations of using the traditional MVC pattern for web applications due to HTTP's stateless nature. Struts implements an MVC2 pattern to address this, using the controller to manage state. The core Struts components like ActionForms, Actions, and ActionMappings are explained. It also covers setting up the Struts controller through configuration files, defining forms and actions, and creating views with JSP and custom tag libraries.
The document discusses ASP.NET MVC framework concepts including:
- MVC architecture divides applications into models, views, and controllers. Models manage state, views display UI, and controllers handle user input and choose views.
- Advantages of MVC include clean separation of concerns, testable UI, reuse of views/models, and organized code.
- The Razor view engine renders HTML from dynamic server-side code using a specially designed parser.
- ASP.NET MVC classes are in the System.Web.Mvc namespace which contains controllers, views, and other core classes.
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe
This document provides an overview of ASP.NET MVC, including its history and key concepts. It describes the MVC pattern and how ASP.NET MVC implements this pattern. It also discusses ASP.NET MVC's project structure, controllers, actions, views, routing and other core features. Finally, it compares ASP.NET MVC to traditional ASP.NET Web Forms and outlines some benefits and disadvantages of the MVC framework.
This document provides an overview of controllers and actions in the MVC framework. It discusses how controllers are responsible for responding to requests, validating actions, and providing data and error handling. It also covers specific controller concepts like ViewData/ViewBag, action attributes, action results, and asynchronous actions.
WPF and Prism 4.1 Workshop at BASTA AustriaRainer Stropek
At BASTA Austria (http://www.basta-austria.at) I did a workshop about WPF and Prism. This is my slide deck. It summarizes the most important take-aways from the workshop. Additionally it contains sample code snippets.
SXA (Sitecore Experience Accelerator) is an out-of-the-box component library and architecture that allows for increased productivity and parallel work. It includes pre-built components, local datasources, and an extended Experience Editor that allows for drag-and-drop page building. SXA uses a Helix architecture and allows for creative exchange where front-end developers can style themes without Sitecore knowledge. It provides conventions for page designs, partial designs, and HTML structure.
The document discusses Sitecore upgrades, including:
1) What a Sitecore upgrade is and the different upgrade methods including incremental upgrades using update packages and migrating content to a clean Sitecore instance.
2) The Express Migration Tool which can help streamline upgrades from older versions like 6.6 and 7.2 to the latest version.
3) Important considerations for upgrades like code compatibility, infrastructure changes between versions, and the importance of testing upgrades before deployment.
The slides from my presentation at the Sitecore User Group Conference in The Netherlands on June 12th, 2015.
Demo source code is available at https://github.com/ParTech/SugCon2015
Inside, you’ll find practical, easy-to-implement strategies that uncover hidden profit opportunities in your daily operations—strategies that drive real growth without added risk.
If you're working harder than ever but not seeing the results you expect, this short read could be the reset your business needs.
2025-05-04 A New Day Dawns 03 (shared slides).pptxDale Wells
Lesson 3 of 6 in a Heritage Bible Master Class study of "A New Day Dawns"
Heritage Bible Master Class meets every Sunday morning at 10:15 at the Heritage Palms Country Club, on the south side of Fred Waring, just east of Jefferson, in Indio, California. Please come check us out!
⭐️ Bitcoin - Mining Race ⭐️ The Fastest Driven Bitcoin Movement ⭐️ english
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invite code - edA6xDgWMVLBAfCClWJy
Mining Race - The fastest growing Bitcoin movement
Join the Ultimate Bitcoin Community Challenge. Race to the Top in Mining Race.
Cryptocurrencies are all about the community. And what better way to fully embrace the BTC community than a community-based mining program?
By participating in the Mining Race, you will not only contribute to the support of the Bitcoin blockchain but also earn more rewards for being a part of the Mining Race community!
Ready to join the Bitcoin Mining Race Challenge?
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invite code - edA6xDgWMVLBAfCClWJy
Speech 3-A Vision for Tomorrow for GE2025Noraini Yunus
This SlideShare presentation explores critical choices ahead for Singapore as GE2025 approaches. It highlights the Singapore United Party's manifesto—a roadmap to balance innovation with sustainability, compassion with ambition, and inclusivity with excellence. Through affordable housing, equitable education, and accessible healthcare, Noraini Bte Yunus champions a thriving society. This inspiring message invites Singaporeans to unite, rise above challenges, and build a resilient, forward-looking nation. Together, we can turn aspirations into reality. Moving Forward, Together!
1. Sitecore MVC
How to implement Sitecore using MVC Presented by Ruud van Falier
2. Topics
The basic concept of (Sitecore) MVC
Sitecore renderings related to MVC
Views
Models
Controllers
Inversion of Control
Dependency Injection
MVC vs. WebForms
Need input: named parameters / URL routing
5. The basic concept of MVC
View
Model
Controller
User
Uses
Manipulates
Updates
Sees
6. The basic concept of MVC
Views display a certain set of data.
They do not know where the data comes from.
Models are classes that hold data.
They may also execute logic for managing this data.
They do not know how the data is displayed.
Controllers are classes that execute logic that controls
what data is seen and which view is used to display it.
7. The basic concept of MVC
Browser URL Routing Controller Model View
Request
Invoke action
Initialize
Lookup view
Render
HTML
An ASP.NET MVC request
8. The basic concept of MVC
A Sitecore MVC request
Source: Martina Welander
Request
httpBeginRequest
pipeline
MVC
route?
Layout
specified?
Is it an MVC
view file?
Controller
specified?
MVC
request
WebForms
request
No No No
No
Yes Yes Yes
Yes
12. Views
Do
Display data from a model
Use simple flow logic that is
required to present data (if /
foreach / retrieval methods)
Don’t
Add complex logic
Go nuts with inline code
13. Sitecore renderings related to MVC
View Rendering
Renders a View using a built-in controller action.
The controller passes a model of type RenderingModel to the View.
Controller Rendering
Calls an action on a controller and lets the controller handle the View rendering.
16. Models
public class ContentPageModel
{
public string Title { get; set; }
public string Intro { get; set; }
public string Body { get; set; }
}
public class ContentPageModel
{
public string Title { get; set; }
public string Intro { get; set; }
public string Body { get; set; }
public ContentPageModel Parent { get; set; }
public IEnumerable<ContentPageModel> SubPages { get; set; }
}
public class ContentPageModel
{
/* Snipped properties */
public void CreateSubPage(ContentPageModel model)
{
// Logic for creating a sub page.
}
public void DeleteSubPage(ContentPageModel model)
{
// Logic for deleting a sub page.
}
}
17. Models
Do
Hold data
Provide logic to manipulate
data
Don’t
Add presentation elements to
data
Use for application logic
20. Controllers
Do
Retrieve data required to
initialize models
Initialize models
Return appropriate View (or
other ActionResult)
Don’t
Cramp them with logic
Use them if it’s not necessary
21. Inversion of Control
“A software architecture with this design inverts control as compared
to traditional procedural programming: in traditional programming, the
custom code that expresses the purpose of the program calls into reusable libraries
to take care of generic tasks, but with inversion of control, it is the reusable code
that calls into the custom, or problem-specific, code.”, Wikipedia
The decoupling of dependencies by isolating code for certain
responsibilities into separate libraries and referring to those libraries
using their interfaces instead of their concrete implementation.
22. Inversion of Control
Inversion of control serves the following design purposes:
To decouple the execution of a task from implementation.
To focus a module on the task it is designed for.
To free modules from assumptions about how other systems do
what they do and instead rely on contracts.
To prevent side effects when replacing a module.
23. public class MvcDemoController : Controller
{
public ViewResult NewsOverview()
{
// Get news root item from Sitecore.
Item newsRoot = Sitecore.Context.Database.GetItem("{NEWS-ROOT-GUID}");
IEnumerable<Item> newsItems = newsRoot.Children;
// Get temperature from weather service.
var weatherService = new WeatherService();
int temperature = weatherService.GetTemperature();
// Initialize model for News Overview page.
return this.View(new NewsOverviewModel
{
NewsItems = newsItems,
Temperature = temperature
});
}
}
TIGHT COUPLING
24. public class MvcDemoController : Controller
{
private readonly ISitecoreContext sitecoreContext;
private readonly IWeatherService weatherService;
public MvcDemoController(ISitecoreContext sitecoreContext, IWeatherService weatherService)
{
this.sitecoreContext = sitecoreContext;
this.weatherService = weatherService;
}
public ViewResult NewsOverview()
{
// Get news root item from Sitecore.
Item newsRoot = this.sitecoreContext.ItemManager.GetItem("{NEWS-ROOT-GUID}");
IEnumerable<Item> newsItems = newsRoot.Children;
// Get temperature from weather service.
int temperature = this.weatherService.GetTemperature();
// Initialize model for News Overview page.
return this.View(new NewsOverviewModel
{
NewsItems = newsItems,
Temperature = temperature
});
}
}
LOOSE COUPLING
25. Dependecy Injection
There are several methods for Dependency Injection, some examples are:
Constructor injection (as seen in the example)
Parameter injection
Setter injection
.. and more
Use a framework that handles Dependency Injection for you
• Windsor container (because it ships with Glass)
• Ninject
• Autofac (TODO: Check)
26. public class MvcDemoController : Controller
{
private readonly ISitecoreContext sitecoreContext;
private readonly IWeatherService weatherService;
public MvcDemoController()
: this(new SitecoreContext(), new WeatherService())
{
}
public MvcDemoController(ISitecoreContext sitecoreContext, IWeatherService weatherService)
{
this.sitecoreContext = sitecoreContext;
this.weatherService = weatherService;
}
}
27. OH MY GOD, THAT’S SO NOT FAIR!
MVC vs. WebForms ?!
28. MVC vs. WebForms
Why MVC is better
• Simpler page lifecycle.
• No more server controls.
• Multiple forms on a page.
• No more ViewState.
• Very easy to work with AJAX.
• Not bound to generated markup.
WebForms is just an extremely complex abstraction
over HTML/JS, made up before the birth of jQuery and
AJAX; we don’t need this abstraction anymore.
Let me know if you need more reasons
When to stick to WebForms
• Legacy application
• Team knowledge
• Prototyping
29. References
Follow me on Twitter: @BrruuD
Contact me by e-mail: [email protected]
Read our blog: www.partechit.nl/blog
This presentation will become available online after the
Sitecore User Group Conference on the 23rd of May in Utrecht, The Netherlands.
More info and tickets: www.sugnl.net