Book Image

ASP.NET 3.5 Social Networking

By : Andrew Siemer
Book Image

ASP.NET 3.5 Social Networking

By: Andrew Siemer

Overview of this book

Table of Contents (19 chapters)


Social networking has become a driving force on the Internet. Many people are part of at least one social network, while more often people are members of many different communities. For this reason many business people are trying to capitalize on this movement and are in a rush to put up their own social network. As the growth of social networks continues, we have started to see more and more niche communities popping up all over in favor of the larger, all-encompassing networks in an attempt to capture a sliver of the market.

In this book, we will discuss the many aspects and features of what makes up the majority of today's social networks or online communities. Not only will we discuss the features, their purpose, and how to go about building them, but we will also take a look at the construction of these features from a large scale enterprise perspective. The goal is to discuss the creation of a community in a scalable fashion.

What This Book Covers

Chapter 1 gives you an overall structure of this book, that is, what a reader can expect from this book.

Chapter 2 helps you create an enterprise framework to handle the needs of most web applications. It discusses design patterns, best practices, and certain tools to make things easier. It also covers error handling and logging.

Chapter 3 covers registration process by means of an email verification system and a permission system to ensure security. It also touches upon password encryption/decryption techniques.

Chapter 4 covers the creation of a user's profile and an avatar in a manner that is flexible enough for all systems to use. In this chapter, we also implement some form of privacy to allow users to hide parts of their profile that they don't want to share with others.

Chapter 5 shows you how to implement friends, how to search for them, find them in the site's listings, and import your contacts into the site to find your friends.

Chapter 6 helps you create a full blown messaging system that will resemble a web-based email application similar to Hotmail or Gmail. We will also learn how to implement the Xinha WYSIWYG editor in a way that can be re-used easily across the site for complex inputs.

Chapter 7 covers details on how to build a generic media management system that will allow you to host video, photos, resumes, or any number of physical files with minimal tweaking. It also addresses the issue of multi-file uploads—one of the biggest limitations of many web programming environments.

Chapter 8 is all about Blogging. With search engines, users, and security in mind, we invest a part of this chapter to address an issue that plagues many dynamic websites—query string data being used to determine page output.

Chapter 9 discusses the creation of the core features of a message board—categories, forums, threads, and posts. Along with these features, the chapter also implements friendly URLs to make our content more suitable for search engine optimization.

Chapter 10 covers the concept of Groups. It focuses on how groups can be used to bring many different systems together in a way to start creation of sub-communities.

Chapter 11 helps us build three controls to allow our users to express their opinions about various content areas of our site—tagging, rating and commenting. Tagging control allows us to take in tag keywords as well as display all the tags for various levels of our site from specific records. Rating control allows us to configure many options per system object for individual ratings. And commenting control helps users to express very specific opinions regarding our content items.

Chapter 12 focuses on Moderation, that is, the means to manage community provided content using a very simple flagging tool. It also covers methods such as Gagging to deal with habitual rule breakers. Finally, it takes a look at what Cross-site scripting (CSS) is, and some measures that can be taken to address it.

Chapter 13 discusses some concepts to help you support a large number of users on your social network. It starts by looking at some key concepts of web farming. Then it goes on to discuss ways to create and search indexed data, methods to optimize data retrieval and content creation, and finally some mail queuing concepts.

Appendix A covers version control and ways to set up your database. It then moves on to various third-party and open source tools such as StructureMap, NAnt, ReSharper, and so on, which will help you create a stable development platform.

Appendix B discusses unit testing. It starts with NUnit and how it helps in the creation of unit tests. It then moves to NAnt and how it helps automate your building and testing processes. Finally, it explains CruiseControl.NET, and how it can help you finish off the automation aspects.

Appendix C contains entire SQL code from the book.

The appendices A, B, and C are not part of the actual book, but you can download them from Packt's website.

Appendix A is available at //

Appendix B is available at //

Appendix C is available at //

What You Need for This Book

This book describes how to build a Social Network using ASP.NET, C#, and SQL Server. To use this book effectively, you will need access to a version of Visual Studio and SQL Server. Most of this book can be used with the various Express editions of Visual Studio and SQL Express, but you will find that having the Professional edition of Visual Studio will make your work flow more efficient. As we are not just discussing ASP.NET, but are instead more interested in what is needed for the features of social networking, there may be times when we turn to an open source solution. All the examples in this book will clearly point out where to get the needed software, and how to configure that software as we work through our examples.

Who is This Book For

This book is written for ASP.NET and C# developers who want to build an enterprise-grade Social Network, either for their own business purposes or as a contract job for another company. The book assumes you have prior experience of developing web applications using ASP.NET 3.5, C# 3.0, SQL Server 2005/2008, and Visual Studio .NET 2008; it focuses on topics that will be of interest to existing developers—not on providing step-by-step examples for each detail.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Create a new class in the Core.Impl directory called ProfileService."

A block of code will be set as follows:

if (profile != null && profile.ProfileID > 0)
        attributes = _profileAttributeService.GetProfileAttributesByProfileID(profile.ProfileID);
        levelOfExperienceType =
        profile.Attributes = attributes;
        profile.LevelOfExperienceType = levelOfExperienceType;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:

Account account = _accountRepository.GetAccountByID(AccountID);
Profile profile = _profileService.LoadProfileByAccountID(AccountID);
if(profile != null)
    account.Profile = profile;

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this:

"Click the Test Connection button to see if your settings are acceptable."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader Feedback

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 email to , 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, please send us a note in the SUGGEST A TITLE form on or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit to directly download the example code.

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 code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are 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 And also take a look at the author supported site for follow up discussions and help regarding this book.


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide the location address or website name immediately so we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.