APress - Real World ASP.NET - Building a Content Management System (VBL).pdf

(4485 KB) Pobierz
Real World ASP.NET- Building a Content Management System.d…
Real World ASP.NET: Building a Content Management System
by Stephen R.G. Fraser
ISBN: 1590590244
Apress © 2002 (522 pages)
Provides theory, detail and code on CMS, including Version Control,
Workflow, and more.
Real-World ASP.NET—Building a Content
Management System
STEPHEN R. G. FRASER
Copyright © 2002 by Stephen R. G. Fraser
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 (pbk): 1-59059-024-4
Printed and bound in the United States of America 12345678910
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, Jason Gilmore,
Karen Watterson, John Zukowski
Managing Editor: Grace Wong
Copy Editor: Nicole LeClerc
Production Editor: Janet Vail
Compositor: Impressions
Artist: Kurt Krames
Indexer: Rebecca Plunkett
Cover Designer: Tom Debolski
Marketing Manager: Stephanie Rodriguez
Distributed to the book trade in the United States by Springer-Verlag New York, Inc.,175
Fifth Avenue, New York, NY, 10010
and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17,
69112 Heidelberg, Germany.
In the United States, phone 1-800-SPRINGER, e-mail < orders@springer-ny.com >,
or visit http://www.springer-ny.com .
Outside the United States, fax +49 6221 345229, e-mail < orders@springer.de >, or
visit http://www.springer.de .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite
219, Berkeley, CA 94710.
E-mail < info@apress.com >, or visit http://www.apress.com .
The information in this book is distributed on an "as is" basis, 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.
The source code for this book is available to readers at http://www.apress.com in the
Downloads section. You will need to answer questions pertaining to this book in order to
successfully download the code.
To my energy, Sarah, and bundle of joy, Shaina, with love.
30089037.003.png 30089037.004.png 30089037.005.png
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.
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 Webmasters 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.
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.
30089037.006.png
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 to CMSs.
 
Chapter 5 , "Basics of Web 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 server-side technologies. It concludes by
showing Web architectures using the .NET Framework.
 
Chapter 6 , "ASP.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 of
XML that are needed to build a CMS and, in particular, what is needed by
CMS.NET.
 
Chapter 9 , "A 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.
 
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.
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 "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
30089037.001.png
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.
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.
Chapter 1: So, What is a Content
Management System Anyway?
Overview
This seems like an obvious question with which to start the book. Yet, the problem is that
the answer, even if worded plainly, is far from obvious: A content management system
(CMS) is a system that manages the content components of a Web site.
That's it. Seems simple enough, right? Why then, if you ask this question of two or more
different Web professionals, do you get two or more different answers or, more precisely,
two or more different "interpretations" of the preceding answer? The problem revolves
around the ambiguity of the word "content" or, more accurately, the scope of the content
or what portions of the content are contained under the umbrella of a CMS.
Another problem is that nowhere does this definition define what core functionality
makes up a CMS. Most CMSs make their names by how many additional features they
add. A true way of telling whether a CMS is any good is by gauging how well it does the
core functionality that makes up a CMS. Without defining what the core functionality of a
CMS is, there is no level playing field for measuring CMSs against each other.
This chapter will provide the information you need to determine what a content
management system is, hopefully removing the ambiguity of the preceding simple
definition ... which brings us to the first major area of ambiguity.
What Is Content?
Most professionals will agree that content is the "stuff" (don't you love the technical
jargon we software developers throw around?) found on a Web site. This "stuff" on a
Web site can be broken down into two categories:
  The information such as text and images that you see on a Web site when
you visit it
  The applications or software that runs on the Web site's servers and actually
displays the information
Now comes the ambiguity. Some professionals will tell you that the domain of a CMS
consists only of the information, whereas others will tell you that it consists of both the
information and the applications. So, which definition is correct?
At first glance, one might say the all-encompassing definition is a more accurate
explanation of the word "content." The question should be asked, though: Do you need
to manage or can you manage the applications in the same way as the information?
30089037.002.png
Zgłoś jeśli naruszono regulamin