MVC Implementations Playbook. Version 0.92



Similar documents
CrownPeak Java Web Hosting. Version 0.20

CrownPeak Playbook CrownPeak Hosting with PHP

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

WCO Form Connectors. Version 0.90

Metadata Management CMS Extension. Version 0.90

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Google Analytics Playbook. Version 0.92

Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 4 Web Applications MOC 20486

Dev01: Kentico CMS 7 Developer Essentials Syllabus

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

INTERNET PROGRAMMING AND DEVELOPMENT AEC LEA.BN Course Descriptions & Outcome Competency

A Comparative Study of Web Development Technologies Using Open Source and Proprietary Software

SQL Server 2005 Reporting Services (SSRS)

Portals and Hosted Files

Sitecore Dashboard User Guide

Content Delivery Network. Version 0.95

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Oracle Application Development Framework Overview

Web Pages. Static Web Pages SHTML


Transition your MCPD Web Developer Skills to MCPD ASP.NET Developer 3.5 (VB)

Enterprise Application Development in SharePoint 2010

Terms and Definitions for CMS Administrators, Architects, and Developers

WHAT'S NEW IN SHAREPOINT 2013 WEB CONTENT MANAGEMENT

Kentico CMS, 2011 Kentico Software. Contents. Mobile Development using Kentico CMS 6 2 Exploring the Mobile Environment 1

Kentico CMS 5 Developer Training Syllabus

Web Cloud Architecture

CROWNPEAK C# API SYSTEM CONFIGURATION GUIDE VERSION 3.0.1

multiple placeholders bound to one definition, 158 page approval not match author/editor rights, 157 problems with, 156 troubleshooting,

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

VB.NET - WEB PROGRAMMING

2311A: Advanced Web Application Development using Microsoft ASP.NET Course 2311A Three days Instructor-led

Programming Fundamentals of Web Applications Course 10958A; 5 Days

ASP.NET Using C# (VS2012)

Software Architecture for Paychex Out of Office Application

Programmabilty. Programmability in Microsoft Dynamics AX Microsoft Dynamics AX White Paper

Developer Tutorial Version 1. 0 February 2015

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

Course 20489B: Developing Microsoft SharePoint Server 2013 Advanced Solutions OVERVIEW

> Define the different phases of K2 development, including: understand, model, build, maintain and extend

Pentesting Web Frameworks (preview of next year's SEC642 update)

DE-20489B Developing Microsoft SharePoint Server 2013 Advanced Solutions

The Great Office 365 Adventure

ResPAK Internet Module

ASP.NET: THE NEW PARADIGM FOR WEB APPLICATION DEVELOPMENT

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming

Design and Functional Specification

ScanJour PDF 2014 R8. Configuration Guide

Developers Guide. Designs and Layouts HOW TO IMPLEMENT WEBSITE DESIGNS IN DYNAMICWEB. Version: English

Developing Microsoft SharePoint Server 2013 Advanced Solutions

Accessing Data with ADOBE FLEX 4.6

Microsoft Dynamics Training

Advanced Web Application Development using Microsoft ASP.NET

Content Management Implementation Guide 5.3 SP1

ORACLE MOBILE APPLICATION FRAMEWORK DATA SHEET

Drupal CMS for marketing sites

ASP.NET MVC. in Action JEFFREY PALERMO JIMMY BOGARD BEN SCHEIRMAN MANNING. (74 w. long.) WITH MVCCONTRIB, N HIBERNATE, AND MORE.

Performance Testing for Ajax Applications

.NET Best Practices Part 1 Master Pages Setup. Version 2.0

Outbound Upgrade Manual. SDL Tridion Development Lab BV

ASP.NET Overview. Ken Casada Developer Evangelist Developer & Platform Evangelism Microsoft Switzerland

GOA365: The Great Office 365 Adventure

Business & Computing Examinations (BCE) LONDON (UK)

Building an ASP.NET MVC Application Using Azure DocumentDB

TechTips. Connecting Xcelsius Dashboards to External Data Sources using: Web Services (Dynamic Web Query)

Kentico CMS 7.0 Tutorial

WEB APPLICATION DEVELOPMENT. UNIT I J2EE Platform 9

Microsoft Dynamics CRM Adapter for Microsoft Dynamics GP

Notes on how to migrate wikis from SharePoint 2007 to SharePoint 2010

Engagement Analytics Configuration Reference Guide

Describe how to utilize the Publishing API to access publishing settings and content.

SharePoint Integration Framework Developers Cookbook

SAP NetWeaver Portal Development Kits for.net and Java

COMPARISON BETWEEN SPRING AND ASP.NET FRAMEWORKS

Kentico CMS 6.0 Tutorial

SelectSurvey.NET Developers Manual

WebObjects Web Applications Programming Guide. (Legacy)

A Model of the Operation of The Model-View- Controller Pattern in a Rails-Based Web Server

Welcome The webinar will begin shortly

ADS2013: App Development with SharePoint 2013

ultimo theme Update Guide Copyright Infortis All rights reserved

Cache Configuration Reference

metaengine DataConnect For SharePoint 2007 Configuration Guide

EMC Documentum Repository Services for Microsoft SharePoint

ASP &.NET. Microsoft's Solution for Dynamic Web Development. Mohammad Ali Choudhry Milad Armeen Husain Zeerapurwala Campbell Ma Seul Kee Yoon

Digital Asset Management. Version 1.0

R i o L i n x s u p p o r r i o l i n x. c o m 1 / 3 0 /

Developing Microsoft SharePoint Server 2013 Advanced Solutions MOC 20489

This three-day instructor-led course provides students with the tools to extend Microsoft Dynamics CRM 4.0.

Page Editor Recommended Practices for Developers

Embedded BI made easy

2012 LABVANTAGE Solutions, Inc. All Rights Reserved.

1. Tutorial - Developing websites with Kentico Using the Kentico interface Managing content - The basics

Internet Engineering: Web Application Architecture. Ali Kamandi Sharif University of Technology Fall 2007

The Recipe for Sarbanes-Oxley Compliance using Microsoft s SharePoint 2010 platform

Transcription:

Version 0.92

Table of Contents Document History... 3 CrownPeak MVC Implementation Overview... 4 ASP.NET MVC Overview... 5 ASP.NET MVC Benefits... 6 Integrating MVC in CrownPeak... 7 Publishing Content as Separate Data Files... 7 MVC vs. Web Forms... 8 CrownPeak Integration... 9 Deploying ASP.NET MVC with the CrownPeak CMS... 10 Building a Basic ASP.NET MVC Project for use with CrownPeak... 10 Implementing the ASP.NET MVC to CrownPeak CMS... 11 ASP.NET MVC Deployment to CrownPeak Hosting... 12 Notes... 12

2014 CrownPeak Technology, Inc. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission from CrownPeak Technology. Document History Author/Editor Date Reason for Change Version Jason Yoo 01/02/2014 Draft 0.90 Fahd Shaaban 01/06/2014 Edits and new content proposing an approach to implement MVC within CrownPeak 0.91 Paul Taylor 06/23/2014 Edits and write-up based on MVC Reference Architecture 0.92

CrownPeak MVC Implementation Overview The CrownPeak CMS is a publishing CMS that can generate and deploy content in any format and to any destination thanks to its decoupled architecture, flexible templating capability and API. By decoupling the CMS from the hosting environment, a website and its underlying framework and technology is not dependent on the CMS for content retrieval at runtime. This means a customer website can enjoy any technology, whether it be Microsoft.Net, Java, PHP, Ruby on Rails, or even static HTML. The CrownPeak CMS API builds on this by allowing authors and editors to focus on the content, while the CMS Templates ensure that the fully tested and approved server-side code (C#, PHP, Java, Perl etc.) is generated and deployed as expected. Given the CMS decoupled architecture, the content managed in the CMS has to be included in the published pages, essentially baked-in the final output of each web page. For example, this means that for a site with 100 articles, the CMS would essentially generate and deploy via sftp 100 different pages containing the templated look and feel and any server-side code, with the unique content for each article in each published page. This is true even for dynamic pages powered by.net, JSP, PHP, etc. The CMS will generate all the pages and deploy them to their final destination to be served to requesting web browsers. The benefits of this approach are numerous and will be discussed and elaborated upon in future playbooks. More and more customers and/or their agencies are selecting MVC.Net architecture to power their sites. Microsoft offers two flavors of.net, the original Web forms technology based on ASPX pages with or without code behind, and MVC, a model-view-controller approach. MVC, similarly to Web Forms, can be easily implemented in CrownPeak using templates to produce the necessary MVC components, and deployed with the content baked-in to the hosting environment. This document illustrates how this can be accomplished.

ASP.NET MVC Overview ASP.NET MVC is one of the methods of developing ASP.NET applications. ASP.NET MVC Framework is Microsoft s Web Application development framework, the other one being traditional web forms framework. MVC is a standard design pattern that many developers are familiar with. The Model-View- Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The Model represents the application core. The Model is the part of the application that handles the logic for the application data. Often model objects retrieve data from a database. The View displays the data. The View is the parts of the application that handles the display of the data. Most often the views are created from the model data. The Controllers handles the input. The Controllers is the part of the application that handles user interaction. Typically controllers read data from a view, control user input, and send input data to the model. CrownPeak subscribers that have any of the following needs, should consider developing in ASP.NET MVC: Separate data (Model), business logic (Controller), and presentation (View)? Is JavaScript going to be used extensively or integrate with other client side tools? Looking for good performance application and an Automatic Unit Testing (Find problems early, Simplifies integration etc.)? Planning to reuse the same input logic? Promotes a solid application architecture?

ASP.NET MVC Benefits Project Architecture: Provides clean separation of concerns (SoC) - It makes it easier to manage complexity by dividing an application into the model, the view, and the controller; Enables the full control over the rendered HTML The MVC framework does less rendering and what is rendered is leaner. Integration of ASP.NET MVC application with third party client side tools becomes easy; SEO (Search Engine Optimization) friendly URL and Routing URL s are friendlier to search engines. Rich routing features treats every URL as a resource supporting REST (Representational state transfer) full interfaces; Enables Test Driven Development (TDD) The MVC controller is a separate class so automatic testing is possible featuring Test Driven Development; Reusability Controllers are not bound to any specific view and so can be reused for multiple views; Better Performance: No View State/Post Back - It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application. There will not be any automatic state management that reduces the page size and therefore impacts performance; Support for Parallel Development - It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior; Extensibility ASP.NET MVC supports multiple view engines like aspx, razor, and other customized engines if required; Existing ASP.NET Features - ASP.NET MVC framework is built on top of matured ASP.NET framework and thus provides developer to use many good features such as forms authentication, windows authentication, caching, session and profile state management etc.

Integrating MVC in CrownPeak MVC is very different from web forms, but not when it comes to CrownPeak integration. In simple terms, even though MVC separates the core logic and data structure/retrieval (models) from the user interaction and input (Controller), which are combined in Web Forms as code behind, the CrownPeak integration is essentially identical. The objective is to implement the presentation which may include server-side as well as client-side code, after they have been fully tested and approved, as templates. These templates expose the areas within the presentation that is defined as managed content as input form fields. The CMS will then generate static versions of these files, replicating the presentation and backend logic as many times as there are pages and deploys them with the content embedded or baked-in to their final destination. MVC specialists would likely reject this approach of publishing identical views with the only difference being the content, as they believe the content, being the only difference, should be retrieved and populated at run-time. However, MVC is not different from any server-side technology that fundamentally relies on Databases to provide their content. The CrownPeak CMS eliminates this need entirely. Thanks to its decoupled architecture and lack of availability of a public API, the content will need to be deployed to the server as well. There has been implementations where the views are deployed to the web server using standard sftp (or using the CMS to deploy non-templated files), with the content published from the CMS as JSON, XML, or HTML Fragments. This approach DOES work, however, it creates a double maintenance issue. Publishing Content as Separate Data Files The CMS, thanks to its multi-output support, can easily publish any content in any format, including JSON, XML, CSV, etc. Typical approaches of publishing content as data files require the double effort and on-going maintenance of implementing the presentation in the CMS for the purpose of In Context Editing within the CMS. This enables authors and editors to edit the content in context of the full presentation. With the presentation published as non-templated views directly to the web server, this means the views will need to be implemented as templates for the purpose of a complete authoring experience only. However, this results in a double maintenance effort to keep the externally managed views in sync with the implemented presentation. This approach is trouble! CrownPeak recommends implementing the views and publishing them directly with the content baked in to the final destination.

MVC vs. Web Forms Capability Web Forms MVC Presentation Server-side Logic Shared Global Content (Header/Footer) Includes In-line code Web pages deployed as files with an.aspx extension Code behind developed as supporting files with the same name as the pages they support with a.cs extension (for C#), and are deployed in a complied DLL Masterpages can be deployed containing all global content (header, footer), and deployed with a.master extension. The Masterpages are referenced in the.aspx pages. User controls provide include capabilities, and are files deployed as pages with a.ascx extension, and referenced by any.aspx page. C# code can be inserted in-line in any aspx page Deployed as Views with an.cshtml extension Controllers and Models provide the server-side logic. The files are named as the View with Controller or Model appended to the name, with a.cs extension (c#), and are typically compiled and deployed as a DLL. Layout files, which are Views, can be deployed with a.cshtml extension, and referenced by any view. Any view can be included within another view as a Partial View. As such, includes are deployed as standard.cshtml files. C# code can be inserted in a view.

CrownPeak Integration Capability Web Forms MVC Output Template Web Pages containing html, css, js, and any server-side C# code are implemented in output templates Views containing html, css, js, and any server-side C# code are implemented in output templates Input Template Deployment Shared Global Content (Header/Footer) Includes Content placeholders are exposed as editable input form fields. Files are deployed with the content baked-in with an.aspx extension. Navigation Wrappers are configured to publish as master pages with a.master extension. Widgets and other assets can be configured to published as user controls with a.ascx extension, and referenced by other templates using name.aspx and url.aspx. Content placeholders are exposed as editable input form fields. Files are deployed with the content baked-in with a.cshtml extension. Navigation Wrappers are configured to publish as layout files with a.cshtml extension. Widgets and other assets can be configured to published as user controls with a.cshtml extension, and referenced by other templates using name.aspx and url.aspx. Server-side code Compiled and deployed as dll Compiled and deployed as dll

Deploying ASP.NET MVC with the CrownPeak CMS Before starting the development, it is beneficial to solidify the list of the prerequisites. Microsoft Visual Studio or Visual Studio Express (Visual Studio Express is a set of freeware integrated development environments developed by Microsoft as a lightweight version of the Microsoft Visual Studio) Microsoft Framework.NET 3.5 or greater Building a Basic ASP.NET MVC Project for use with CrownPeak Although custom functionality may be wired into the ASP.NET MVC Project, a customer may wish to leverage the page creation and management abilities of the CrownPeak CMS. In this case, we need to create an ASP.NET MVC Controller, which will handle non-custom page rendering. From the Visual Studio Empty MVC Project, within the /App_Start/RouteConfig.cs file (which controls all routing within the application), add a catchall route. This will be called if none of the custom routes above it are hit during a page request. routes.maproute( "CrownPeakPage", "{*page}", new { controller = "CrownPeakPage", action = "Page" ); } Create an ASP.NET MVC Controller to handle anything caught by this route. Create a controller at /Controllers/CrownPeak/CrownPeakPageController.cs, with the following: public class CrownPeakPageController : Controller { ""); public ActionResult Page() { if (Request.Url == null) return null; var absolutepath = Request.Url.AbsolutePath.Replace(Request.ApplicationPath, if (!absolutepath.startswith("/")) absolutepath = "/" + absolutepath; if (absolutepath == "/") absolutepath = ConfigurationManager.AppSettings["CrownPeak:DefaultHome"]; var viewfile = GetViewFileLocation(absolutePath); if (System.IO.File.Exists(Server.MapPath(viewFile))) return View(viewFile); Response.StatusCode = 404; Return

View(GetViewFileLocation(ConfigurationManager.AppSettings["CrownPeak:Default404"])); } private static string GetViewFileLocation(string viewfile) { return new StringBuilder().Append(ConfigurationManager.AppSettings["CrownPeak:ViewsRoot"]).Append(viewFil e).append(configurationmanager.appsettings["crownpeak:viewsfileextension"]).tostring(); } } Finally, set-up the necessary application settings within the Web.config: <appsettings> <add key="crownpeak:viewsroot" value="~/views/crownpeak" /> <add key="crownpeak:viewsfileextension" value=".cshtml" /> <add key="crownpeak:defaulthome" value="/index" /> <add key="crownpeak:default404" value="/404" /> <add key="crownpeak:default500" value="/500" /> </appsettings> This is a catchall route, that will handle any page request, which was not caught by a developer s custom routes. This functionality will examine the request URL, and look for a corresponding ASP.NET MVC View file at /Views/CrownPeak/{request_url} and display it. If this is not found, it will redirect the user to /404, or if error occurs, to /500. Implementing the ASP.NET MVC to CrownPeak CMS Once the ASP.NET MVC Project is ready to compile, the ASP.NET MVC needs to be implemented in CrownPeak s CMS in the following way: 1. Compile the ASP.NET MVC project and publish from within Visual Studio; 2. Create a folder within the root of the CrownPeak CMS application, and import all compiled code into here. Set the folder s publishing properties to publish to the root of the website; 3. Templatize all the view files (*.cshtml) in CMS; 4. Create a folder in the root of the CrownPeak CMS application to hold the site content (this should be named logically, e.g. /EN for English language content). Set the folder s publishing properties to publish to /Views/CrownPeak, and set the filename.aspx template file to include the.cshtml extension on all published files.

ASP.NET MVC Deployment to CrownPeak Hosting Before publishing the content, it is beneficial to check with CrownPeak IT Team if the hosting environments are ready for ASP.NET MVC. Please send a help ticket to support@crownpeak.com. Microsoft Framework.NET 3.5 or greater is required.net Framework Version for an Application pool needs to be set as 4.0 in IIS. Notes All new CrownPeak hosting servers are running on Windows Server 2012 with IIS 8.0 and Microsoft Framework.Net 4.0. Courtesy domain names (Stage/Live) will be provided by CrownPeak IT Team; An ASP.NET MVC Reference Architecture has been built, and should be examined and understood prior to beginning this type of integration.