Real-World ASP.NET: Building a Content Management System



Similar documents
Real-World ASP.NET Building a Content Management System STEPHEN R. G. FRASER

Microsoft Dynamics GP. Workflow Installation Guide Release 10.0

Maximizing Performance and Scalability with IBM WebSphere

Microsoft Dynamics GP. econnect Installation and Administration Guide Release 9.0

Success with Microsoft Dynamics CRM 4.0

Beginning Excel What-If Data Analysis Tools

CrysDev: A Developer s Guide to Integrating Crystal Reports

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

System Requirements for Microsoft Dynamics NAV 2013 R2

Administrator's Guide

TIBCO Spotfire Web Player 6.0. Installation and Configuration Manual

Scribe Demonstration Script Web Leads to Dynamics CRM. October 4,

IIS 6: The Complete Reference

MicrosoftDynam ics GP TenantServices Installation and Adm inistration Guide

Microsoft Dynamics GP SQL Server Reporting Services Guide

Microsoft Dynamics GP Release. Workflow Administrator s Guide

.CRF. Electronic Data Capture and Workflow System for Clinical Trials

ADP Workforce Now Security Guide. Version 2.0-1

AppFabric. Pro Windows Server. Stephen Kaufman. Danny Garber. Apress. INFORMATIONSBIBLIOTHbK TECHNISCHE. U N! V En SIT AT S R!

ResPAK Internet Module

TIBCO Administrator User s Guide. Software Release March 2012

Microsoft Dynamics GP 2010

Trend Micro Incorporated reserves the right to make changes to this document and to the products described herein without notice.

Microsoft Dynamics GP. Engineering Data Management Integration Administrator s Guide

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

Oracle Procurement. Punchout and Transparent Punchout Guide for Oracle iprocurement and Oracle Exchange Release 11i. Part No.

Dell Statistica Document Management System (SDMS) Installation Instructions

Management Center. Installation and Upgrade Guide. Version 8 FR4

CRM to Exchange Synchronization

WebEx Event Center User's Guide

Microsoft Dynamics GP Release

GOOGLE ADSENSE QUICK GUIDE

DIGIPASS Authentication for Microsoft ISA 2006 Single Sign-On for Outlook Web Access

WebEx Meeting Center User Guide

Oracle Fusion Middleware

Pro SQL Server Reporting Services. Third Edition. mm m. Brian McDonald. Shawn McGehee. Rodney Landrum. Apress*

STEP BY STEP IIS, DotNET and SQL-Server Installation for an ARAS Innovator9x Test System

Content Management Implementation Guide 5.3 SP1

TIBCO Spotfire Automation Services 6.5. Installation and Deployment Manual

Business Portal for Microsoft Dynamics GP. Electronic Document Delivery Release 10.0

VERITAS Bare Metal Restore 4.6 for VERITAS NetBackup

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

Microsoft Dynamics GP. Electronic Signatures

Learn AX: A Beginner s Guide to Microsoft Dynamics AX. Managing Users and Role Based Security in Microsoft Dynamics AX Dynamics101 ACADEMY

Microsoft Dynamics GP. Electronic Signatures

Visual COBOL ASP.NET Shopping Cart Demonstration

Contents Introduction xxvi Chapter 1: Understanding the Threats: Viruses, Trojans, Mail Bombers, Worms, and Illicit Servers

DIGIPASS KEY series and smart card series for Juniper SSL VPN Authentication

Excel 2007 PivotTables Recipes

Retention Policy Module Admin and User Guide

DEPLOYMENT GUIDE Version 2.1. Deploying F5 with Microsoft SharePoint 2010

Using Ruby on Rails for Web Development. Introduction Guide to Ruby on Rails: An extensive roundup of 100 Ultimate Resources

Business Portal for Microsoft Dynamics GP. Project Time and Expense Administrator s Guide Release 10.0

How to Log in to LDRPS-Web v10 (L10)

Interworks. Interworks Cloud Platform Installation Guide

WebEx Meeting Center User s Guide

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

How To Train Aspnet

Microsoft Dynamics GP Web Services Installation and Administration Guide

K2 Designer for SharePoint Hands-On Exercise - Leave Request process

Server Installation Guide ZENworks Patch Management 6.4 SP2

Microsoft Dynamics GP. Field Service - Preventive Maintenance

Landing Page 101: Learn the Top 100 Tips to Landing Pages - Improve your ROI with Quality Landing Pages, Now Create Landing Pages that truly convert.

Installing Globodox Web Client on Windows Server 2012

Catálogo de cursos plataforma elearning Microsoft Imagine Academy: Microsoft SQL Server y Visual Studio

Microsoft Expression Web Quickstart Guide


Microsoft Dynamics GP econnect Installation and Administration Guide

WebMarshal User Guide

FOR WINDOWS FILE SERVERS

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

Sentinel Installation Guide

Identikey Server Getting Started Guide 3.1

Marco A. M. de Melo & Fernando S. P. Gonçalves MANAGER

MathXL Getting Started Guide for Students

SafeGuard Enterprise Web Helpdesk. Product version: 6.1

aspwebcalendar FREE / Quick Start Guide 1

Trend Micro Incorporated reserves the right to make changes to this document and to the products described herein without notice.

Microsoft Dynamics NAV

Michael Miller. 800 East 96th Street, Indianapolis, Indiana 46240

Xerox Multifunction Devices. Verify Device Settings via the Configuration Report

Appendix A How to create a data-sharing lab

WebEx Event Center User's Guide

DOCUMENTATION FILE RESTORE

Working with Microsoft Dynamics CRM Mike Snyder Jim Steger Kristie Reid

Secret Server Installation Windows 8 / 8.1 and Windows Server 2012 / R2

CS SoftDent Practice Management Software Installation Guide for Client/Server Configurations

Omgeo OASYS Workstation Installation Guide. Version 6.4 December 13, 2011

Skynax. Mobility Management System. System Manual

Microsoft Dynamics GP. Electronic Signatures

Pro-Watch Software Suite Installation Guide Honeywell Release 4.1

Microsoft Small Business Financials. Small Business Center Integration

TIBCO BusinessConnect Trading Partner Administration. Software Release 6.0 November 2011

How to Create Effective Training Manuals. Mary L. Lanigan, Ph.D.

Web Portal Installation Guide 5.0

Transcription:

Real-World ASP.NET: Building a Content Management System STEPHEN R. G. FRASER APress Media, LLC

Real-World ASP.NET: Building a Content Management System Copyright 2002 by Stephen R. G. Fraser Originally published by Apress in 2002 All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-59059-024-9 DOI 10.1007/978-1-4302-0832-7 ISBN 978-1-4302-0832-7 (ebook) Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Editorial Directors: Dan Appleman, Peter Blackburn, Gary Cornell, Iason Gilmore, Karen Watterson, John Zukowski Managing Editor: Grace Wong Copy Editor: Nicole LeClerc Production Editor: JanetVail Compositor: Impressions Artist: Kurt Krames Indexer: Rebecca Plunkett Cover Designer: Tom Debolski Marketing Manager: Stephanie Rodriguez For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. E-mail info@apress. corn, or visit http: 1 /www. apress. corn. The information in this book is distributed on an "as is" hasis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.

To my energy, Sarah, and bundle ofjoy, Shaina, with love.

Contents at a Glance About the Author.... xiii Introduction.... xv Chapter 1 So, What Is a Content Management System Anyway? 1 Chapter 2 Version Control Chapter 3 Workflow 2 9.41 Chapter 4 Personalization 57 Chapter 5 Basics of Web Architecture Chapter 6 ASP.NET, C#, and Visual Studio.NET Chapter 7 Database Development and ADO.NET Chapter 8 XML........... Chapter 9 A Quick Overview of CMS.NET Chapter 10 Initializing CMS.NET Chapter 11 Getting Content into the System Chapter 12 Cookies, Authentication, Authorization, and Encryption.... Chapter 13 Displaying Dynamic Content Chapter 14 Using a Workflow to Enter Content Chapter 15 Registered Users and Protected Content 77.. 99..133..185.. 229 267. 299-345.387.427-473 v

Contents About the Author.... xiii Introduction.... xv Chapter 1 So, What Is a Content Management System Anyway?.... 1 What Is Content?.... 1 Real-World Content.... 3 What Is a Content Component?.... 5 The CMS Elements... 6 What Is a Content Management System?..... 18 Some Common CMS Features.... 19 What Are the Benefits of a CMS?..... 24 When Do You Need a Commercial CMS?.... 27 Summary.... 28 Chapter 2 Version Control.... 29 What Is Version Control?.... 29 What Is Version Tracking?.... 32 What Is Rollback?.... 33 The Roles of Version Control in a CMS..... 34 Benefits of Version Control and Tracking.... 37 Summary.... 39 Chapter 3 Workflow....41 What Is a Workflow?....42 Workflow Components....43 What Is a Workflow's Role in CMS?..... 50 Building CMS Workflows.... 53 Benefits of a Workflow.... 55 Summary.... 56 vii

Contents Chapter 4 Personalization.... 57 What Is Personalization?.... 57 Personalization Objectives.... 59 Types of Personalization.... 63 Law of Diminishing Returns.... 68 Privacy.... 70 Role of Personalization in a CMS... 71 Benefits of Personalization.... 74 Summary... 76 Chapter 5 Basics of Web Architecture... 77 Basic Web Architecture.... 78 What Are Clients and Servers, Web Style?..... 82 Web Programming before NET.... 87 Web Programming Using NET..... 95 Summary.... 98 Chapter 6 ASP. NET, C#, and Visual Studio. NET.... 99 The Simple Dynamic Content Viewer..... 99 Summary.... 131 Chapter 7 Database Development and ADO. NET.... 133 Visual Studio.NET's Database Utilities.... 133 What Is ADO.NET?.... 146 Examples of ADO.NET Development.... 152 Summary.... 183 Chapter 8 XML.... 185 What Is XML?.... 185 Where Is XML Used in Web Architecture?.... 188 XmlReader, XmlWri ter, and XPathNavigator.... 190 XML Examples.... 192 Summary.... 227 viii

Contents Chapter 9 A Quick Overview of CMS.NET.... 229 What Is CMS. NET?.... 230 Installing CMS. NET.... 230 A Brief Tutorial.... 247 Summary.... 266 Chapter 10 Initializing CMS. NET.... 267 To Set Up or Not to Set Up?..... 268 First, Describe the Process.... 271 Using web.config to Save the Database Connection String.... 273 Setting Up the All-Powerful Administrator.... 282 Database Helper Classes and Stored Procedures.... 286 Finally, Wrap Up the Installation....295 Summary.... 298 Chapter 11 Getting Content into the System.... 299 Breaking a Page into Frames..... 299 The XML-Driven NavBar.... 303 First CMS. NET Administration Page.... 305 Content Database Table.... 306 Listing Site Content.... 307 Creating New Content.... 314 Error Handling.... 319 Updating Content.... 322 Viewing a Piece of Content.... 331 Removing Content.... 337 Submitting Content.... 340 Summary.... 343 Chapter 12 Cookies, Authentication, Authorization, and Encryption.... 345 ASP.NET Web Application Security..... 346 CMS. NET Security Structure.... 346 Cookies and Session Objects.... 348 ix

Contents Authentication.... 351 Authorization.... 360 Encryption.... 369 Restricting the CMA.... 374 NavBar Update for Handling Roles.... 374 Account Maintenance.... 376 Summary.... 386 Chapter 13 Displaying Dynamic Content.... 387 What Is Dynamic Content?.... 387 Three- Level Content Navigation.... 388 Starting and Stopping the Web Site.... 391 Navigational Database Tables.... 398 User Controls.... 401 Standard CMS. NET User Controls....402 The Default Home Page Web Form....406 The HeadlineTeaser User Control....411 The Default Content-Domain Web Form.... 414 The Default Zone Web Form....418 The Default Story Web Form....421 Deploying Content....424 Summary.... 425 Chapter 14 Using a Workflow to Enter Content....427 CMS. NET Content Workflow....428 CMS.NET Roles.... 429 Interrole Communication....432 The Authoring Phase....439 The Editing Phase....447 The Approval Phase....458 The Deployment Phase....462 Summary.... 471 X

Contents Chapter 15 Registered Users and Protected Content....473 Why Protect Content?....474 Privacy Policy.... 474 What Are User Profiles?....476 Methods of Gathering User Information....477 Registration Using the Slow Retrieval Method....478 Logging into a Restricted Area....481 Logging Off.... 491 Restricting Content to Registered Users....492 Summary.... 504 xi

About the Author Stephen Fraser is the managing principal for Fraser Training, a corporate training company focusing on.net technologies. Stephen has over 15 years of IT experience working for a number of consulting companies, ranging from the large consulting firms of EDS and Andersen Consulting (Accenture) to a number of smaller e-business companies. His IT experience covers all aspects of application and Web development and management, ranging from initial concept all the way through to deployment. Stephen currently resides, with his beautiful wife Sarah and daughter Shaina, in beautiful Louisville, Kentucky. xiii

Introduction I've played with many of the commercial content management systems (CMSs) currently on the market, and many have certain qualities or features in common. There is one thing, however, that they all have in common: They are all overpriced. Yes, they have hundreds of features. The fact is that when most Webmasters implement a CMS, they usually don't even come close to using half of the features provided by the CMS. Yes, a few Web sites are exceptions, but most don't need all the features and, unfortunately, they don't have anything available as a substitute, or so they believe. This book will show that Web masters have an alternative because it describes the ins and outs of a CMS. It goes as far as showing you how to build one of your own-cms.net. But even if you never plan to write your own CMS, this book and, in particular, CMS.NET will help you understand what is happening under the covers of its more expensive siblings. Programmers (and I am one, so I can say this) like to make the world think that what they do is very mystical. In reality, it is actually very easy, if you have enough information and the right tools at hand. This book should be enough of a head start that most good programmers could, on their own, pump out a commercial-grade CMS in less than a year. Heck, I coded CMS.NET in just over three months while writing this book. The quick development time can be directly attributed to the power of Microsoft's.NET and Visual Studio.NET. It saved me from many of the problems that occurred when I tried to develop an equivalent CMS using other, nearly as powerful, competitive tools. What Is This Book About? This book is about CMSs (I'm sure you figured that out from the front cover), but more specifically, it is a detailed programmer's look at what makes up, and how to develop, a CMS using Microsoft's new ASP. NET, C#, and the.net Framework. Ultimately, it is a book that shows how to build a fully functional CMS at a fraction of the cost of its commercial siblings. Even if you plan to buy a much more expensive CMS, this book will explain the internal details of a CMS and should help you make the correct decision when you make your purchase. XV

Introduction Who Is This Book Written For? This book is for Web developers who want to learn the internal details of a CMS or who want to create a CMS of their own. With this book, a Web developer should gain a good understanding of how to build a CMS and where to find a lot of the code (prepackaged) needed to build one. It is for Webmasters who want a more cost -effective way to maintain their Web content. This book will show that a Webmaster may, in fact, have another choice when it comes to his CMS. It is also for any intermediate- to advanced-level Web developers who already have a basic understanding of the Microsoft.NET Framework and want to continue to expand their knowledge. It is designed to provide a lot of helpful coding hints using C#, ASP. NET, XML, and ADO.NET, within the Visual Studio.NET environment, in the area of server-side Web development. What Is in This Book? The following is a chapter-by-chapter breakdown of the book's contents: Chapter 1, "So, What Is a Content Management System Anyway?" introduces the basic concepts of a CMS by breaking one down and explaining its most basic elements. The chapter then continues by describing some common features and benefits of most CMSs. Finally, it wraps up with a discussion on when a commercial CMS is really merited. Chapter 2, "Version Control," covers version control, tracking, and rollback in detail. It shows how a CMS uses versioning, why it is important, and its benefits. Chapter 3, "Workflow," covers workflows, a very important feature found in all CMSs. It shows what a workflow is, the roles it plays, and the benefits it provides to a CMS. The chapter also discusses some things that a workflow designer needs to examine when building the workflow. Chapter 4, "Personalization," starts by defining personalization and walks through its objectives. It then explores many of the different types of personalization available on the market today. It covers two major issues of personalization: the law of diminishing returns and privacy. The chapter concludes with the roles and benefits that personalization provides tocmss. xvi

Introduction Chapter 5, "Basics ofweb Architecture," first discusses Web architectures in general and their three layers: database, application, and presentation. Then it delves into the presentation layer in greater detail, showing how it is divided into server and client sides communicating using HTTP. The chapter then covers some of the more common client- and serverside technologies. It concludes by showing Web architectures using the.net Framework. Chapter 6, ~sp.net, C#, and Visual Studio.NET," is a little refresher on C#, ASP.NET, and Visual Studio.NET. It is designed to get everybody on a level playing field when it comes to.net Framework development. Chapter 7, "Database Development and ADO.NET," covers all essential aspects of database development needed to develop a CMS system. Chapter 8, "XML," covers in great detail some of the many ways in which a developer can access XML through the.net Framework. It covers all facets ofxml that are needed to build a CMS and, in particular, what is needed by CMS.NET. Chapter 9, ~Quick Overview of CMS.NET," starts with a brief description of CMS.NET and then goes into how to install it. The chapter finishes off with a brief tutorial. Chapter 10, "Initializing CMS.NET," covers the setup subsystem of CMS.NET. It starts by showing how to navigate from page to page. Then it discusses web.config and how to programmatically update and extract information from it. The chapter also shows how CMS.NET separates application development and database development with the use of database helper classes. Chapter 11, "Getting Content into the System," covers the CURVeS (creating, updating, removing, viewing, and submitting) of CMS.NET's content management application. It shows how to break a Web page into frames and then revisits XML with the XML-driven NavBar (Navigation Bar). The chapter also covers error handling in some detail. It finishes by covering the Content database and its helper class. Chapter 12, "Cookies, Authentication, Authorization, and Encryption," covers security-in particular, cookies, authentication, authorization, and encryption. It starts with a brief discussion of ASP.NET's security and then covers CMS.NET's security in more detail. xvii

Introduction Chapter 13, "Displaying Dynamic Content," first covers the basics of what dynamic content is. Then it shows dynamic content in practice within CMS.NET's three-level dynamic navigation model. The chapter also covers both static and dynamic User Controls in detail. Chapter 14, "Using a Workflow to Enter Content," covers role-based content administration. It describes CMS.NET's workflow and the roles it requires. It also discusses inter-role communication and e-mail alerts. Chapter 15, "Registered Users and Protected Content," covers registering users and restricting content. It starts by describing why you might want to restrict content and covers the privacy policy Web page. It then covers user profiles and the two most common methods of retrieving user information: the quick blitz and the slow retrieval. The chapter ends by showing how to change CMS.NET to implement registration and protected content. Conventions I've tried to keep the number of different styles used in this book to a minimum. You didn't buy it for pretty icons, but rather its content (I hope). Here are examples of the styles used and explanations of what they mean: Important words and words being defined are in italic font. Bold font is use for things you must enter into an edit field. Code font is used for code, URLs, and e-mail addresses that appear in regular text. Every once in a while I will include a Note, Tip, or Warning about something: NOTE Pay attention. xviii

Introduction TIP Tricks that might help. WARNING Danger ahead. Code that is highlighted in gray can mean one of two things: it is code that you need to enter yourself, or it is code of direct interest to you. Gray background code looks like this: public Content(string h, string s) { headline - h; story - s; Otherwise, code has been autogenerated by Visual Studio.NET or it is something you have entered a while ago and has no bearing on what you are coding now: <%@ Page language="c#" Codebehind="DCViewer.aspx.cs" AutoEventWireup "false" Inherits="Ch06Example.WebForm1" %> <! DOCTYPE HTML PUBLIC "-I /W3C/ /DTD HTML 4.0 Transitional/ /EN" > <HTML> Obviously, if some of the code is autogenerated and some is manually entered, you will find both styles in the code at the same time. xix

Introduction How to Reach the Author I would like to hear from you. Feel free to e-mail me at srgfraser@contentmgr. com. I will respond to every e-mail that I can. Questions, comments, and suggestions are all welcome. Also, feel free to visit a copy of CMS.NET on the Internet at. www. contentmgr. com. All registered users have the capability to author content on the site if they feel so inclined. Also, the www. contentmgr. com site is where the newest release of CMS.NET can be found, along with any user /reader contributions. Oh, by the way, thank you for buying my book. XX