You are previewing ASP.NET 3.5 Social Networking.
O'Reilly logo
ASP.NET 3.5 Social Networking

Book Description

In Detail

Social Networking is all about developing connections or ties between friends and associates. While people have always networked with one another the Internet has allowed us to network with people all over the world easily. Any interest or cause can support its own social network, where fans and followers can meet, chat, and share their views. But building a social networking site from scratch involves some complex logic, and some serious coding.

This book shows how to build a scalable, enterprise-ready social network using ASP.NET. The book uses the latest features of ASP.NET to provide a platform that is efficient, easy to maintain, and extensible. Whether you want to build your own social network, are developing a social site for a customer or employer, or just want a practical guide to developing complex ASP.NET applications then this book is ideal for you.

The book starts by planning the essential features of our social network, and then building a 'community framework' that will give our site a solid foundation and enable us to add all our social networking features. We then go on to create user accounts, profile pages, messaging systems, 'friend' relationships between members, media galleries, blogs, message boards, groups, and more. Along the way you will see LINQ, MVC, AJAX, and other features of ASP.NET 3.5 put to practical and interesting uses.

What you will learn from this book?

  • Make key decisions about architecture and the tools to use

  • Build a solid 'community framework' to give your site a strong foundation; the principles explored this framework will apply to any large-scale web application

  • Create user accounts, set up a permissions system, and handle password encryption

  • Work with user profiles, and establish 'friend' relationships between different users

  • Let users customize their profile and communicate with one another

  • Understand core concepts of LINQ to SQL and work with it in a layered environment

  • Moderate the site, ensuring safety, dealing with cross-site scripting (XSS), privacy, and decency

  • Utilize the Model View Presenter pattern with ASP.NET 3.5 to enable Test Driven Development

  • Add an internal search engine using SQL Server and Lucene.NET

  • Work with appropriate design patters to create a scalable long-lasting enterprise framework

Approach

Each chapter starts by showing the user experience we are going to create in the chapter. It then has a section discussing the major design decisions we face in building these features, and finally presents the 'solution' - including the overall architecture and highlighting the most important code elements.

The book presents a lot of real-world code, with comprehensive explanation and discussion. The full social network application is available for download from the Packt website, for you to examine, study, and modify.

Who this book is written 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.

Table of Contents

  1. ASP.NET 3.5 Social Networking
  2. Credits
  3. About the Author
  4. About the Reviewer
  5. Preface
    1. What This Book Covers
    2. What You Need for This Book
    3. Who is This Book For
    4. Conventions
    5. Reader Feedback
    6. Customer Support
      1. Downloading the Example Code for the Book
      2. Errata
      3. Piracy
      4. Questions
  6. 1. Social Networking
    1. What makes this topic so important
      1. Large communities
      2. Niche communities
    2. Once I have my own social network, then what?
      1. Customer service
      2. Content moderation
      3. Growing infrastructure requirements
    3. Our social network—Fisharoo
    4. This book's approach
      1. Problem
      2. Design
      3. Solution
    5. Features of our social network
      1. Accounts
      2. Profiles
      3. Friends
      4. Messaging
      5. Media galleries
      6. Blogging
      7. Message boards
      8. Groups
      9. Comments
      10. Tags
      11. Ratings
      12. Framework
      13. Scaling up
    6. Summary
  7. 2. An Enterprise Approach to our Community Framework
    1. A layered architecture versus a non-layered architecture
      1. Layers
    2. Domain-driven Design
      1. Ubiquitous language
      2. Entities
      3. Value objects
      4. Services
      5. Modules
      6. Aggregates
      7. Factories
      8. Repositories
    3. Model View Presenter pattern
      1. Model
      2. View
      3. Presenter
      4. How it works
    4. Factory pattern using StructureMap
    5. Repository pattern and LINQ
    6. Wrappers for everything!
      1. Configuration
      2. Cache
      3. Session
      4. Redirection
      5. Email
    7. Error handling and logging
      1. Error handling
      2. Logging
    8. Summary
  8. 3. User Accounts
    1. Problem
    2. Design
      1. Registration
        1. Accounts
        2. Password strength
        3. Terms and conditions
        4. CAPTCHA
        5. Email confirmation and verification
      2. Security
        1. Permissions
        2. Password encryption/decryption
      3. Logging in
        1. Password reminder
        2. Manage account
    3. Solution
      1. Implementing the database
        1. The Accounts table
        2. The Permissions table
        3. The AccountPermissions table
        4. The Terms table
        5. Creating the relationships
      2. Implementing the data access layer
        1. Setting up LINQ for the first time
        2. A DataContext wrapper
        3. Building repositories
          1. Selecting accounts
          2. Saving an account
          3. Deleting an account
          4. Adding permissions to an account
        4. The other repositories
          1. Permissions repository
          2. Terms repository
      3. Implementing the services/application layer
        1. Extension methods
      4. Implementing the business/domain layer
      5. Implementing the presentation layer
        1. Model view presenter
          1. View
          2. Presenter
          3. Model
        2. Registration page
        3. Email verification
        4. Password recovery
        5. Edit account
        6. Implementing security
          1. SiteMap
          2. SiteMap wrapper
          3. All nodes
          4. Navigation
          5. Checking access
          6. Security
          7. Implementing navigation and security
    4. Summary
  9. 4. User Profiles
    1. Problem
    2. Design
      1. Profile
        1. Manage profile
      2. Avatar
        1. Custom avatars
        2. Gravatar
      3. Public profile
        1. Custom homepage
      4. Privacy
      5. News feed
    3. Solution
      1. Implementing the database
        1. The Profiles table
        2. Level of Experience
        3. The Attributes table
        4. The Privacy table
        5. The Alerts table
        6. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
      3. Implementing the services/application layer
        1. ProfileService
        2. Account service
        3. Privacy service
        4. Alert service
        5. Profile Attribute Service
      4. Implementing the presentation layer
        1. Privacy
          1. Manage privacy
        2. Manage profile
        3. Avatar
          1. Upload avatar
          2. Image manipulation
          3. Gravatar
        4. Public profile
          1. Custom homepage
        5. News feed
    4. Summary
  10. 5. Friends
    1. Problem
    2. Design
      1. Friends
      2. Finding Friends
        1. Searching for a Friend
        2. Inviting a Friend
        3. Importing Friends from External Sources
        4. Sending an Invitation
        5. Adding Friend Alerts to The Filter
      3. Interacting With Your Friends
        1. Viewing Your Friends
        2. Managing your friends
        3. Following Your Friends
        4. Providing Status Updates to Your Friends
    3. Solution
      1. Implementing the Database
        1. The Friends Table
        2. Friend Invitations
        3. Status Updates
        4. Creating the Relationships
          1. Friends Constraints
          2. FriendInvitations constraints
          3. StatusUpdates constraints
      2. Setting Up the Data Access Layer
        1. Building Repositories
          1. FriendRepository
          2. FriendInvitationRepository
          3. StatusUpdateRepository
          4. AccountRepository
      3. Implementing the Services/Application Layer
        1. FriendService
        2. AlertService
        3. PrivacyService
      4. Implementing the Presentation Layer
        1. Searching for Friends
          1. SiteMaster
          2. Search
        2. Invite Your Friends
        3. Outlook CSV Importer
          1. Importing Contacts
          2. Selecting Contacts
        4. Confirm Friendship
          1. Login
          2. Registration
        5. Show Friends
        6. Friends on Profile
        7. Status Updates
    4. Summary
  11. 6. Messaging
    1. Problem
    2. Design
      1. Messages
      2. Recipients
    3. Solution
      1. Implementing the database
        1. Messages
          1. MessageTypes
        2. MessageRecipients
          1. MessageRecipientTypes
          2. MessageStatusTypes
          3. MessageFolders
        3. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
          1. MessageRepository
          2. MessageRecipientRepository
      3. Implementing the services/application layer
        1. MessageService
        2. Email
        3. AlertService
        4. FriendService
      4. Implementing the presentation layer
        1. New message
          1. Friends control
        2. Default (or Inbox)
          1. Folders
        3. Read message
    4. Summary
  12. 7. Media Galleries
    1. Problem
    2. Design
      1. Files
      2. Folders
      3. File upload
      4. File system management
      5. Data management screens
    3. Solution
      1. Implementing the database
        1. Files
        2. File system folders
        3. File types
        4. Folders
        5. Folder types
        6. Account folders
        7. Account files
        8. Folder files
        9. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
          1. FileRepository
          2. FolderRepository
      3. Implementing the services/application layer
        1. FolderService
      4. Implementing the presentation layer
        1. File upload
          1. Receiving files
          2. Testing our receiver
          3. Multi-file upload
        2. Photo albums
          1. MyPhotos
          2. ViewAlbum
    4. Summary
  13. 8. Blogs
    1. Problem
    2. Design
      1. Blogs
    3. Solution
      1. Implementing the database
        1. Blogs
        2. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
      3. Implementing the services/application layer
        1. AlertService
      4. Implementing the presentation layer
        1. Latest blog posts
        2. My blog posts
        3. Fancy URL support
        4. View post
        5. Create or edit post
    4. Summary
  14. 9. Message Boards
    1. Problem
    2. Design
    3. Categories
      1. Forums
      2. Threads and Posts
      3. Friendly URLs
      4. Alerts
    4. Solution
      1. Implementing the Database
        1. Categories
        2. Forums
        3. Posts
        4. Creating the Relationships
      2. Setting Up the Data Access Layer
        1. Building Repositories
          1. BoardCategoryRepository
          2. BoardForumRepository
          3. BoardPostRepository
      3. Implementing the Services/Application layer
        1. BoardService
        2. AlertService
      4. Implementing the Presentation Layer
        1. Default.aspx
        2. Redirector
        3. UrlRewrite
        4. ViewForum.aspx
        5. ViewPost.aspx
        6. Post.aspx
    5. Summary
  15. 10. Groups
    1. Problem
    2. Design
      1. Groups
      2. GroupMembers
      3. GroupTypes
      4. GroupForums
      5. Schema
    3. Solution
      1. Implementing the database
        1. Groups
        2. GroupMembers
        3. GroupTypes
        4. GroupForums
        5. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
        2. GroupRepository
          1. GetGroupByForumID
          2. IsOwner
          3. CheckIfGroupPageNameExists
          4. DeleteGroup
        3. GroupToGroupTypeRepository
          1. SaveGroupTypesForGroup
        4. GroupForumRepository
        5. GroupMemberRepository
          1. GetMemberAccountIDsByGroupID
          2. DeleteGroupMembers
        6. GroupTypeRepository
        7. AccountRepository
          1. GetApprovedAccountsByGroupID
        8. GetAccountsToApproveByGroupID
      3. Implementing the services/application layer
        1. GroupService
          1. IsOwnerOrAdministrator
          2. SaveGroup
        2. AlertService
        3. Redirector
        4. WebContext
      4. Implementing the presentation layer
        1. ManageGroup
          1. WYSIWYG
          2. Image upload
        2. Members
          1. Data pagination
          2. CheckBoxLists without the CheckBoxList control
        3. Default
        4. UrlRewrite
        5. ViewGroup
          1. Private/Public
        6. MyGroups
        7. Forum enhancements
    4. Summary
  16. 11. Comments, Tags, and Ratings
    1. Problem
      1. Ratings
      2. Tagging
      3. Commenting
    2. Design
      1. Ratings
      2. Tags
      3. Comments
    3. Solution
      1. Implementing the database
        1. SystemObjects
        2. Ratings
        3. System object rating options
        4. Tags
        5. System object tags
        6. Comments
        7. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
        2. RatingRepository
          1. HasRatedBefore()
          2. GetCurrentRating()
          3. SaveRatings()
        3. SystemObjectRatingOptionRepository
        4. TagRepository
          1. GetTagByName()
          2. GetTagByID()
          3. GetTagsGlobal()
          4. GetTagsBySystemObject()
          5. GetTagsBySystemObjectAndRecordID()
        5. SystemObjectTagRepository
          1. GetSystemObjectByTagID()
        6. CommentRepository
          1. GetCommentsBySystemObject()
      3. Implementing the services/application layer
        1. TagService
          1. AddTag()
          2. CalculateFontSize()
        2. Extensions
          1. ShuffleList()
        3. WebContext
          1. SelectedRatings
          2. ClearSelectedRatings
          3. TagID
        4. Configuration
      4. Implementing the presentation layer
        1. Comments Page
          1. Comments.ascx
          2. Comments.ascx.cs
          3. CommentsPresenter.cs
        2. Ratings Page
          1. Ratings.ascx
          2. Ratings.ascx.cs
          3. RatingsPresenter.cs
        3. Tags Page
          1. Tags.ascx
          2. Tags.ascx.cs
          3. TagsPresenter.cs
        4. Installing the new user controls
        5. UrlRewrite.cs
        6. Tags page
          1. Tags.aspx
          2. Tags.aspx.cs
          3. TagsPresenter.cs
    4. Summary
  17. 12. Moderation
    1. Problem
      1. Community moderation
      2. Gagging users
      3. Dynamic filter
        1. Cross-site scripting (XSS)
    2. Design
      1. Moderation
      2. Gags
      3. Filtering
    3. Solution
      1. Implementing the database
        1. Moderations
        2. Gags
        3. ContentFilters
        4. Creating the relationships
      2. Setting up the data access layer
        1. Building repositories
          1. ModerationRepository
            1. GetModerationsGlobal()
          2. GagRepository
          3. ContentFilterRepository
      3. Implementing the services/application layer
        1. ContentFilterService
        2. Extensions
      4. Implementing the presentation layer
        1. Moderation
          1. The user control
          2. Moderating flagged content
        2. Gagging
        3. Filtering
    4. Summary
  18. 13. Scaling Up
    1. Problem
    2. Design
      1. Database optimization
        1. Flagged for delete
        2. Indexing
        3. Partitioning
      2. Web farming
      3. Caching
      4. Searching
      5. Email
    3. Solution
      1. Database optimization
        1. Indexing
        2. Partitioning
          1. FileGroups
          2. Partition function
          3. Partition scheme
          4. Partition tables
          5. How does this affect our current system?
        3. Gotchas
      2. Web farming
      3. Caching
        1. The server
        2. The client
        3. Using the client
        4. Starting the cache layer
        5. Where do I start?
      4. Searching
        1. Getting Lucene.NET
        2. Building indexes
        3. Building the search
      5. Email
        1. Creating services to send email
        2. The database
        3. Services
        4. Serializing email
        5. Connecting the new DBMailQueueService
        6. The queue
        7. Processing the queue
    4. Summary