This project is read-only.


A Simple and Small Asp.Net MVC social networking, messaging engine.

Do you want to add the simple messaging, friends and group interaction to your website, but don't want to go for a complete CMS based solution? Are you using microsoft’s Asp.Net role based security and want to provide interaction between your website users? Or do you want to know the basics of social networking so that you can easily add them to your website if needed? Parichay is an attempt to help you address your intention.

Although Asp.Net Social Networking book is an amazing read, but still it carries a lot of information and the code contains quite a big (and of course efficient) framework for social network. In Parichay, we would try to Keep It Short and Simple(KISS)

Therefore, Parichay is a Short and Simple Asp.Net Social Networking and messaging website starter app. The application has been designed with KISS(Keep it Short and Simple) principle in mind. We will use Asp.Net MVC 3 (with razor) as web application framework. NHibernate will be used for data persistence framework - which will give our project the portability to several databases.

Of course, if you are looking for a well attested, well beaten track, you would prefer to go with a complete cms based solution, and add social networking to it as a plugin module. Still, this article will give you an Idea about what you mayconsider if you are develping your own social networking module. Further, this app can easily be converted into a CMS module as it has been designed as an independent module with least of dependencies to the security layer.

(Please Note:- This application doesn’t have one-click installer. Remember to go to the INSTALLATION section for information about installation. Basically - you'll need to:-
  • Create a database(e.g. create database parichaytest)
  • Create tables using SQLs provided (1ParichaySecurity.sql & 2ParichayData.sql)
  • Update the NHibernate connection string in Web.Config )

For more explanation, please read :- Parichay (A Simple & Small Asp.Net MVC Social Network Starter)

In addition to the default role based security, we will be using another simple layer of permission based security - as a simple httpmodule (info. can be found here codeproject )

2. Overview

As mentioned earlier, we will be using the default Asp.Net role based security. We will be adding a simple layer of permission based security to it as an httpmodule. (more info. about this module can be found in this article.

Here is the basic overview of this article and components we'll be talking about:-
  1. Introduction and Background (Discussed Above)
  2. Overview
  3. Modules (Tables=>Db Objects and their respective Controller-Actions)
    1. Member Details: (User Details, Password & Password Q&A mgmt., Recovery etc.)
    2. Member Alerts: (Simple track of your website activity and responses.)
    3. Member Messages: (Status Updates sharing and receiving replies/responses to your thoughts.)
    4. Member Friends: (Connecting with other Existing/External users to the system)
    5. Member Requests: (finding and sending Friend/Group/Other request to existing users.)
    6. Member Invitations: (Inviting friends from outside)
    7. Member Groups: (Discussion groups, Making publicly visible/private groups, Managing groups{currently all groups are public only managed by admin})
    8. Member Uploads: (Uploading images to the site)
    9. System Administration: (Blocking/Unblocking/Managing/Deleting users, Roles and Permissions)
    10. System Logs: (The track of website hiccups)
  4. Points of Interest (Some Interesting and re-usable pieces of code for developers)
  5. Using the Code
  6. Installation
  7. History

Using the code

The current application has been tested over MySql database. The first thing you will do is to create the database and run the table scripts. The MySql database script has been provided with the solution.

For databases, other than MySql you might prefer to enable the createschema functionality to NHibernate helper class which should create the database schema from the Mapping Files. Or you can create the table scripts yourself and change the Nhibernate parameters in the web.config file of the application.

For initial seeding of the database, you can either run the initial seeding script which will create the user with name sysadmin and default password "password", and then add this user as Admin of the website.

*Currently you can simply sign-up with username "sysadmin" and the application will add you to the "Admin" role. The following loop has been added to the "Account>>Register" controller to ensure this:

  • Please note that auto installer has not been created for this app. Kindly create the MySql Database first. e.g.- with name "parichaytest" and install the two SQL scripts provided.
  • The 1ParichaySecurity.sql contains the schema for Security.
  • 2ParichayMessaging.sql contains the schema for Messaging tables.
  • Change the name of NHibernate "connection string" in the web.config of the application to point to your database.
    • e.g., Enable & Update following settings for MySql Database in Web.Config file. (Update the DB name, Username, Password etc):-
       <property name="show_sql">true</property>
      <property name="use_outer_join">true</property>
      <property name="use_proxy_validator">false</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <property name="connection.isolation">ReadCommitted</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
      <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
      <property name="connection.connection_string">Server=localhost;Database=parichaytest;User ID=**Your DB UserId**;Password=**yourdbpasswrd**;Convert Zero Datetime=true</property>
  • Enable & Update following settings for SQL Server in Web.Config file:-
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=.\sqlexpress;Initial Catalog=parichaytest;User ID=**Your DB UserId**;Password=**yourdbpasswrd**</property>
      <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
      <property name="show_sql">true</property>

  • Build and run the application.
  • Remember to sign up with "sysadmin" username. The system will assign you the "Admin" role. Once the sysadmin is already created for you. You can comment out the following code block in the "Account>>Register" Controller action:-
if ((string.Equals(model.UserName,"sysadmin",StringComparison.InvariantCultureIgnoreCase))&&(Roles.GetAllRoles().Length == 0))
                        Roles.AddUserToRole(model.UserName, "Admin");

  • The current system has been tested with MySql database. For other databases you can either generate the schema from mapping files. To do this, you will need following code in NHibernateHelper classes of "Parichay.Security" and "Parichay.Data" projects:-
cfg.AddAssembly(typeof (aClassFromYourProject).Assembly);
new SchemaExport(cfg).Execute(false, true, false, false); 

Information can be found here and here

*After setting up the database, remember to update the NHibernate connection string in Web.Config file of the application.

The support for MS-SQLServer is added now. SQL Server script will be added to the project soon as the table relationships are created and tested.

Last edited Feb 23, 2012 at 8:01 AM by okdone, version 8


No comments yet.