34,79 €
Microsoft's ASP.NET Community Starter Kit (CSK) is a powerful, freely available application that allows you to quickly create a fully featured community-driven website, complete with article and news management, downloads, forums, and user handling. Supported and tested by thousands of developers in the ASP.NET community across the world, the Community Starter Kit offers you the luxury of a scalable and extensible architecture, and the ability to brand your own site. This book will take you inside the Community Starter Kit, allowing you to harness its power for easily creating your own websites. The book is structured to help you understand, implement and extend the Community Starter Kit:
Understand how the Community Starter Kit works.
Build the skills to implement your own site.
Develop the confidence to extend the system for your own needs.
With this book, you will learn how to:
Install and configure the CSK
Find your way around the CSKs towering range of features
Create and administer community websites
Become familiar with the common CSK ASP.NET controls
Customize your CSK site
Discover the secrets of the CSK core architecture
Explore the inner workings of CSK modules
Extend the CSK by creating new modules
Customize existing modules with Web controls
Add an RSS feed to share your content with others
Deploy your CSK website
This book is for ASP.NET developers with a sound grasp of C# and access to Visual Studio .NET. This book uses the Visual Studio. NET version of the ASP.NET Community Starter Kit available from http://www.asp.net/StarterKits/
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 292
Veröffentlichungsjahr: 2004
Copyright © 2004 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First edition: May 2004
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 1-904811-00-0
www.packtpub.com
Cover Image by www.visionwt.com
Authors
K. Scott Allen
Cristian Darie
Technical Reviewers
Ovidiu Platon
Dave Ranck
Colin Mumford
Commissioning Editor
Douglas Paterson
Layout
Niranjan Jahagirdar
Technical Editors
Deepa Aswani
Saurabh Bijur
Dipali Chittar
Indexer
Vijay Tase
Proofreaders
Chris Smith
Vijay Tase
Helen Wood
Cristian Darie is an experienced programmer specializing in various Microsoft and open source technologies, and relational database management systems. Having worked with computers since he was old enough to press the keyboard, he initially tasted programming success with a first prize in his first programming contest at the age of 12, and from there moved on to many other similar achievements in years that followed. As an eagle-eyed technical reviewer with Wrox Press, Cristian was tempted into writing and has since co-authored several .NET and database books for Wrox Press and Apress, including Beginning ASP.NET E-Commerce and The Programmer’s Guide to SQL.
Cristian is currently building a large community website using the Community Starter Kit for University "Politehnica" of Bucharest. He can be contacted through his personal website at http://www.CristianDarie.ro.
K. Scott Allen is the Chief Software Architect for Medisolv, Inc., and holds MCP and MCSD certifications. In 12 years of software development, Scott has worked on everything from real-time firmware in 8-bit embedded devices to highly scalable Internet applications connecting COM+ and J2EE components with web services. Living in Hagerstown, Maryland, Scott tries to play as much softball as possible during the summer. Scott is a cofounder of the site http://www.OdeToCode.com, a .NET developer resource built using the Community Starter Kit. You can reach Scott at <[email protected]>.
I would like to thank Douglas Paterson and Poonam Lall for their generous help and support while working on this book.
The ASP.NET Community Starter Kit allows you to quickly create a fully featured community-driven website, complete with article and news management, downloads, forums, and user handling. Available for free from Microsoft, this application puts a staggering range of functionality into your hands, and either by using it as is, or customizing it to your requirements, you are giving your projects a great head start.
Supported and tested by thousands of developers in the ASP.NET community across the world, the Community Starter Kit offers you the luxury of a scalable and extensible architecture, as well as the ability to control the look and feel of your site.
The book is structured to help you understand, implement, and extend the Community Starter Kit; it will take you inside the Community Starter Kit, allowing you to harness its power for easily creating your own websites.
Chapter 1 introduces the Community Starter Kit (CSK), and shows how to install it so you are up and running.Chapter 2 takes us on a tour of the sample community website that ships with the CSK — the Lunar .NET community. This chapter is your orientation to the features and functionality provided by the CSK, and is our first step towards creating our own community website.
InChapter 3 we see how to administer the data that gets displayed by the CSK, and learn how to manage our community, and multiple communities on the same installation, through the various administration tools provided by the CSK.
The Community Starter Kit has been designed from the ground up to support easy integration of skins and styles, allowing you to change the look and feel of your site with ease. InChapter 4 we take a detailed look at themes, skins and the common controls that control the overall appearance of your site. Before we delve into the CSK framework and architecture, we have a quick walkthrough of implementing a completely new CSK site inChapter 5.
Understanding the core architecture of CSK is essential if you want to extend the system or even modify the existing code. InChapter 6 we’ll learn how the Community Starter Kit builds the client pages, and what are the major classes that drive it.
InChapter 7 we look inside one of the modules that ship with the CSK to gain an overall view of the structure of a CSK module.
With knowledge of how to work with the administrative features and an understanding of the inner workings of the CSK, inChapter 8 we move on to extending the CSK by creating a new module: a Frequently Asked Questions module. The strategies and principles learned in this chapter will prepare you for developing custom modules to add your own functionality to the CSK.
Creating a new module from scratch is not the only way to customize the CSK application, and inChapter 9, we look at customizing through the use of user control (.ASCX) files. The flexibility of the CSK is further demonstrated inChapter 10, where we build an RSS feed to syndicate the output from any part of the site.
The final chapter of the book,Chapter 11, shows how to deploy a CSK website to a production environment, and tackles preparing the web server, and deploying both the code and the database to your hosting setup.
This book has been written for ASP.NET developers with a sound grasp of C#. To use this book you need to have the following:
This book uses the C#, Visual Studio. NET version of the ASP.NET Community Starter Kit available from:
To install and run the ASP.NET Community Starter Kit, you will need the following:
Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply drop an e-mail to <[email protected]>, making sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, then please send us a note in the Suggest a title form on www.packtpub.com or e-mail <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, then see our author guide on www.packtpub.com/authors.
Visithttp://www.packtpub.com/support, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.
The downloadable files contain instructions on how to use them.
Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in text or a code error — we would be grateful if you could report this to us. By doing this you can save other readers from frustration, and also help to improve subsequent versions of this book.
If you find any errata, you can report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata have been verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
You can contact us at <[email protected]> if you are having a problem with some aspect of the book and we will do our best to address it.
Everybody agrees that .NET brought in many improvements over previous development paradigms and technologies. The drawback with new technologies is that developers need time to master the new skills; the large code bases, solutions, techniques, and expertise that were available with older technologies are no longer applicable within the framework of new technologies. It is always more difficult to build a complex solution with a technology you haven’t yet mastered, no matter what that technology is.
In order to help developers become more efficient with ASP.NET, Microsoft has released a number of starter kits that help ASP.NET developers to create their own solutions in a faster and easier manner.
The ASP.NET Starter Kits are complete solutions that you can update and customize for your own needs. When building complex applications, designing the application architecture is often a time-consuming step. Borrowing the entire architecture from an existing solution can be of immense help if the job is done right.
At the time of writing, there were five starter kits available for download at http://www.asp.net/starterkits (visit the site for more information on these):
The names of the starter kits are self-describing.
This book is exclusively dedicated to the Community Starter Kit (CSK), which is the most complex and powerful of all the starter kits. It provides a complete application that can be adjusted exclusively using the administrative interface included within the starter kit without touching a single line of code or knowing its internal working.
In the first five chapters, you’ll learn how to create your own customized solution by using the administrative interface that comes with the Community Starter Kit application. In Chapters 6 through 11, you will learn how to programmatically create new modules and plug them into the site.
The CSK helps you to create and administer online community websites by providing the complete source code for a carefully tested, scalable, and modular structure that can be reused and customized to suit your particular needs.
Community websites are websites that support online communities. These can be regional user communities, developer resource sites, news sites, or other kinds of user‑group sites. Most community websites provide features such as presenting news and events concerning the community, photo galleries, links to other websites, discussion forums, and so on.
The CSK application itself is quite complex but can save you many hours of design and development efforts. It is built using powerful and flexible 3-tier architecture with reusable components and offers good performance. We’ll discuss the details of the architecture starting withChapter 6, but an example of its modularity is that the application, excluding the administration pages, has only two ASPX web forms. Each client page is dynamically built using separate web user controls and data gathered from the SQL Server database.
By default, the CSK comes with out-of-the box functionality that includes support for nine types of content including articles, books, events, photo galleries, downloads, user polls, and more. It also supports features such as moderation, upload quotas, comments, user polls, ratings, newsletters, advertisements, web services, and security. We’ll take a detailed look at each of these in Chapters 2 and 3.
To see how these features work, you can preview the Lunar .NET community (the sample community that ships with the CSK) at http://www.asp.net/CommunityStarterKit/.
The CSK has built-in functionality for skinnable interfaces, which means you can change its appearance entirely through its administration interface and configuration files without modifying a single line of code.
An advantage of using the CSK is that a number of Internet Service Providers (ISPs) support automatic deployment of websites that are based on it. We’ll talk more about deployment techniques and strategies inChapter 11.
The license agreement for the ASP.NET Starter Kits specifies that apart from some restrictions, you’re allowed to use them for any commercial or non-commercial purposes. Thus, you’re allowed to create your own websites based on the CSK code and use them for your own needs.
The complete license agreement terms for using the starter kit application can be found at http://www.asp.net/samplessourcelicense. Even though the terms are pretty relaxed, please read them carefully before starting to create your websites based on the CSK.
Before moving on to the installation details, make sure you have met the necessary system requirements:
You can’t use the CSK with Windows XP Home Edition because it doesn’t include IIS.
Before installing the starter kit, make sure you have the appropriate software and hardware environment. If you don’t have SQL Server, you can install it from the Visual Studio .NET kit or from its official homepage, http://www.microsoft.com/sql/msde/. You can install IIS by going to the Windows Components Wizard located at Control Panel | Add/Remove Programs | Add/Remove Windows Components.
Once you have your system ready for the CSK, it’s time to download the starter kit from http://www.asp.net/starterkits.
Before downloading the starter kit, you are offered the option to create a user account for the ASP.NET Forums. The CSK discussions provide useful insight about developing solutions using the CSK.
After you go to the Download Starter Kit link in the CSK section, you’ll need to choose what version of the starter kit to download.
There are six versions of the CSK available for download for the three standard .NET languages provided by Microsoft: C#, VB.NET, and J#. For each of these languages, you can download the SDK version or the VS (Visual Studio .NET) version. The SDK version doesn’t use code-behind files and is more appropriate for development environments like Web Matrix.
Web Matrix is a free ASP.NET development tool that you can download from http://www.asp.net/webmatrix and its installer kit is only 1.3 MB. It doesn’t support all the features you can find in Visual Studio .NET, such as support for code-behind files, IntelliSense, or debugging, but can be very useful for developing small ASP.NET applications. For more information about Web Matrix, visit: http://aspnet.4guysfromrolla.com/articles/061803-1.aspx or http://www.aspnetpro.com/productreviews
There is no difference in functionality between the different versions of the starter kit. The only difference is the language they’re written in and the way they are packaged.
This book focuses on the CSVS version of the starter kit, which is a C# ASP.NET web application for Visual Studio .NET. The file download for this starter kit is named ASP.NET Community (CSVS) Installer v1.0.msi.
After downloading the MSI file, the installation shouldn’t raise any problems. At the beginning, you’re presented with some useful details about the system requirements and the installation location:
The actual web locations, admin name, and password may differ since you have the option to change them during installation.
After accepting the license agreement for Microsoft ASP.NET Starter Kit, you’ll have the option to specify:
A single CSK installation can support multiple communities. During the setup, the installer creates a single sample community whose administrator account is Admin. Admin is a local community account and has privileges only inside its community. The ISPAdmin account, on the other hand, is not part of any community. ISPAdmin is used to access the ISP administration pages, where you can manage the communities in the CSK installation.
That’s it — the CSK is now ready for action! The installer also populates the database with a sample community named Lunar .NET (an imaginary community for .NET programmers on the moon station) that you can see in action right away. If you haven’t changed the default virtual directory name, you can visit the Lunar .NET community at http://localhost/CommunityStarterKit:
Generally, the installation process works well; however, there have been some reports on the ASP.NET forums with problems installing the kit. Typical problems are related to the connection string used to access the CommunityStarterKit database. The connection string is stored in the Web.Config file in the CSK project folder. Also, the CSK installer program creates a log file named install.log in the setup folder. This is also a good place to look for the root of your problem.
As mentioned earlier in the chapter, you can change the appearance of the website using the administrative interface. This is because the underlying architecture is based on skins. With only a few clicks, it’s possible to completely change the face of the site. The following screenshot shows one of the themes included in the starter kit:
In this chapter, we took the first step into the world of CSK. We briefly discussed what the Community Started Kit can do. We discussed the system requirements necessary to install the CSK and went through the installation process.
This starter kit can prove to be a very useful tool in your web development toolbox. It was designed with both usability and reusability in mind, and with its powerful and flexible infrastructure, building customized community websites becomes a straightforward task. Our next step will be towards learning how to customize and extend the CSK.
In the next chapter, we’ll take a journey through the features bundled with the CSK.
It’s time to make a trip to the moon. Touring the Lunar .NET community, the sample community website that ships with the Community Starter Kit (CSK), will help you learn about the features and functionality bundled in the starter kit. The first step towards creating your own community website based on the CSK is to get accustomed to its functionality.
Lunar .NET implements almost all the functionality supported by the starter kit engine. After this tour, you might find that the CSK includes everything you need for your own website and more.
Chapters 3, 4, and 5 will teach you how to create a community website by reusing what you already have. In the later chapters, you’ll learn how to extend the CSK by creating new modules.
In this chapter, we aim to:
Let’s load the Lunar .NET community in Internet Explorer. If you installed the CSK with the default options, you can access it at http://localhost/CommunityStarterKit. The following screenshot shows the default look of the main page of the Lunar .NET community:
It’s assumed you’re running the CSK on your local machine. If this is not the case, you’ll need to refer to the machine that hosts the remote community instead of localhost. Also, if you chose to use a different virtual directory when installing the kit, you’ll need to use that name instead of CommunityStarterKit in the URL.
The main page in the Lunar .NET community contains the elements expected of any community website: a logo, a menu with links to various sections, an advertising banner, and so on. In this chapter we learn how the built-in functionality works, and inChapter 3 we’ll learn how to administer it through the Community Administration Menu.
Bear in mind that it’s possible to completely change the layout of a CSK website by building new skins (as we’ll learn inChapter 4) or using the predefined themes that ship with the CSK.
You can preview the predefined themes at http://localhost/CommunityStarterKit/Admin/help/theme.htm.
The community logo appears in the upper left part of the site. It can be changed by editing the logo of the home page in the Community Administration Menu.
The community menu is just below the logo, and contains links to the sections of your community. Each section in the community has a content type, such as Books, Links, or Photo Galleries. Each content type is governed by a specific CSK module (such as Books module, Articles module, and so on).
You can have several sections in your community website with the same content type. For example, you can have two Books sections named "C# Books" and "VB.NET Books", both built using the Books module.
We’ll discuss the CSK modules and the different types of content supported by the CSK later in this chapter.
The Search box permits searching for content in the section that is being visited or in all public sections of the website. The following screenshot shows this feature in action:
We’ll discuss how the search functionality works internally inChapter 6.
The main page features the Login and Register links for unauthenticated users and the Log Off and Edit Profile sections for logged in users. Their functionality is obvious, and we’ll analyze them in detail in the Creating and Using User Accounts section later in this chapter.
At the top and in the right of the main page, you can see two advertising boxes generated by AdRotator controls. InChapter 3, we’ll discuss how to configure the ads to be displayed.
Web Boxes are used to display information outside of the main content area of your pages. In the Lunar .NET community site, by default, you can see a random quote box and a list of new photos in the right side of the page.
Web Services Boxes are similar to Web Boxes, except that they get their source information from an external RSS feed. By default, you can see information gathered from the official Star Wars website in the right part of the page.
The community administrator can add voting polls through the Community Administration Menu. You can see in the following screenshot how the voting poll looks by default:
The main page content area changes depending on the type of community section being viewed. The home page, which is a parent section, shows links to the other sections of the website. If you go to one of these sections, the contents section will change accordingly. We’ll see more about each kind of website section later in this chapter, and inChapter 3, we’ll see how to change these sections using the Community Administration Menu.
Now let’s learn more about each type of content supported by the CSK by playing further with the Lunar .NET community.
In the following sections, we will look at:
In this chapter, we aim at having a good overview and knowledge about the capabilities of these modules. We will discuss their functionality with more details inChapter 3 while learning how to administer them using the Community Administration Menu.
The Articles page of the Lunar .NET community can be accessed by clicking on the Mission link. The Articles module first shows a list of the articles in the current section:
While logged in as Admin, apart from the usual content, you can also see the following elements:
The roles that are allowed to read, edit, delete, or add articles for a section can be set by the administrator in the Community Administration Menu | Edit Sections | Edit Section | Security menu. However, the administrator account always has those privileges.
When the Read More link is clicked, the article details page is shown:
Note the Edit this Article and Delete this Article links, which appear only when you are logged in as administrator.
When editing or adding a new article, an easy-to-use interface is provided:
Feel free to play around a little bit and get used to adding and updating articles. Note that for writing in the Extended Text section, you are provided with the HTML Editor (we will look at this in detail later in the chapter).
The Events section shows the upcoming events in your community. You can access this section of the site by clicking on the Events link. The following screenshot shows the display of an event in the Lunar .NET community:
The Events section works in a way similar to the Articles section, except:
There is a View Past Events link that lets you see events that expired and are no longer shown in the main Events page.
Events are automatically ordered by date, so you aren’t provided with up and down links to modify the order in which they appear.
You can access the Books section of the site by clicking on the .NET Books link. The Books section is shown in the following screenshot:
The Books module is similar in functionality to the Articles module, except:
You can access the Links section of the sample website by clicking on the Favorite Links link in the menu. Each link object has a title, URL, and description. By default, there are five link objects listed per page. The administrative buttons allow you to edit, delete, or change the order of links:
The Discussions module is used to host a discussion forum.
Discussions contain threads, and threads contain messages. Users can post new threads in a discussion or new messages in a thread.
On clicking the Discuss link in the menu, you get the Discuss page that contains links to the three discussions (the Private discussion is only visible to community administrators.)
The Discuss page is a parent section that contains three separate discussion topics. Each of those discussions is governed by the Discussions module. The list of discussion topics can only be modified from the Community Administration Menu, which allows adding, removing, and changing website sections.
The following screenshot shows the threads in the Job Board discussion:
Users that visit the discussions can: