MicroBlog

This web application is similar to twitter.com. It allows registered members to post updates, which are displayed to followers of the user. A user can have followers and friends (users who follow this user).

The following are the topics of ASP.NET used in this project.

The following are the major operations in this application.

Steps to download, deploy and run this project

The following are the steps to be taken to run the existing part of the application. This project makes use of membership feature of ASP.NET.
  1. Download MicroBlog.rar and unzip it into any directory in your system. For example, if you extract to c:\ then it will create a directory c:\microblog.
  2. Open Visual Studio.NET 2008 or Visual Web Developer 2008.
  3. Open the project from the directory into which you extracted project. For example, c:\microblog
  4. Select Website->ASP.NET Configuration option
  5. Select Security tab
  6. Select Use the security Setup Wizard to configure security step by step.
  7. Select From Internet option in Step 2
  8. Click on Next button in the remaining screens and finally click on Finish.
  9. It create a database called ASPNETDB.MDF with required tables and other database components
  10. Open the database in Server explorer or Database Explorer and create tables - MB_PROFILES, MB_FRIENDS, MB_UPDATES with the following structure. The following tables show the structure of these tables.

    MB_PROFILES

    userid          uniqueidentifier  (primary key)
    onlinebio       varchar(200)
    picturefile     varchar(20)
    followerscount  int
    friendscount    int
    updatescount    int
    
    Note : userid is linked with userid of ASPNET_USERS table.
    
    
    MB_UPDATES
    updateid        int    identify column (primary key)
    userid          uniqueidentifier
    test            varchar(140)
    timestamp       datetime
    
    Note : userid is linked with userid of ASPNET_USERS table.
    
    MB_FRIENDS
    userid          uniqueidentifier
    friendid        uniqueidentifier
    
    Note: userid is linked with userid of ASPNET_USERS table. friendid is linked with userid of ASPNET_USERS table. Both userid and friendid put together become primary key
    

  11. Create the following trigger for ASPNET_USERS table/li>
    CREATE TRIGGER trg_insert_profile_row
    ON dbo.aspnet_Users
    FOR Insert
    AS
    declare @userid uniqueidentifier
    
     /* insert a row into profiles table */
     select @userid = userid from inserted
     
     insert into mb_profiles values(@userid,'','default_profile',0,0,0);
    
    
  12. Create the following stored procedure in the database.
    CREATE PROCEDURE dbo.mb_addfriend(@userid uniqueidentifier, @friendid uniqueidentifier)
    AS
     begin tran
     begin try
     
       
       insert into mb_friends values(@userid, @friendid)
       
       update mb_profiles set friendscount = friendscount + 1
       where userid  = @userid;
       
       update mb_profiles set followerscount = followerscount + 1
       where userid = @friendid;
       
       commit tran
     end try
     begin catch
       rollback tran
       raiserror('Could Not Add Friend',16,1);
     end catch
    
    
    
    CREATE PROCEDURE dbo.mb_addupdate(@userid uniqueidentifier, @text nvarchar(140))
    as
     begin tran
     begin try
        insert into mb_updates(userid,[text],[timestamp])
        values (@userid,@text, getdate()) 
    
        update mb_profiles set updatescount = updatescount + 1
        where userid = @userid
        commit tran
    end try
    begin catch
       rollback tran
       raiserror('Could not add an update!',16,1)
    end catch
    
    
    
    CREATE PROCEDURE dbo.mb_deleteupdate(@updateid int)
    AS
    declare @userid uniqueidentifier
     begin tran
     begin try
     
       /* get userid for this update */
       select @userid = userid from mb_updates 
       where updateid = @updateid
       
       delete from mb_updates where updateid = @updateid
       
       update mb_profiles set updatescount = updatescount -1 
       where userid  = @userid;
       
       commit tran
     end try
     begin catch
       rollback tran
       raiserror('Could not delete update',16,1);
     end catch
    
    
    CREATE PROCEDURE dbo.mb_findpeople(@userid uniqueidentifier, @pattern  nvarchar(50))
    AS
       select au.userid, username, picturefile, onlinebio, followerscount, friendscount, updatescount
       from mb_profiles p inner join aspnet_users au on (au.userid=p.userid) 
       where au.userid <> @userid and  username like '%' + @pattern + '%' and 
            p.userid not in 
              ( select friendid from mb_friends
                where userid = @userid)
       
       
    
    
    CREATE PROCEDURE dbo.mb_getfriends(@userid uniqueidentifier)
    AS
       select au.userid, username, picturefile, onlinebio, followerscount 
       from mb_profiles p inner join aspnet_users au on (au.userid=p.userid) 
       where p.userid in 
              ( select friendid from mb_friends
                where userid = @userid)
       
    
    CREATE PROCEDURE dbo.mb_gettotalupdates(@userid uniqueidentifier)
    AS
    
     select picturefile,username, text, timestamp from mb_updates u inner join aspnet_users au on (u.userid = au.userid) inner join mb_profiles p on (u.userid = p.userid)
     where  u.userid = @userid 
     union
     select picturefile, username, text, timestamp from mb_updates u inner join aspnet_users au on (u.userid = au.userid) inner join mb_profiles p on (u.userid = p.userid)
     where u.userid in (select friendid from mb_friends where userid = @userid)
     order by  timestamp desc
    
    
    CREATE PROCEDURE dbo.mb_getupdates(@userid uniqueidentifier)
    AS
    
     select updateid,picturefile, username, text, timestamp 
     from mb_updates u inner join aspnet_users au on (u.userid = au.userid) 
        inner join mb_profiles p on (u.userid = p.userid)
     where  u.userid = @userid 
     order by timestamp desc
    
    
    
    
    CREATE PROCEDURE dbo.mb_getuserdetails(@userid uniqueidentifier)
    AS
    
      select onlinebio, picturefile, followerscount, friendscount, updatescount 
      from mb_profiles where userid = @userid
      
    
    
    CREATE PROCEDURE dbo.mb_removefriend(@userid uniqueidentifier, @friendid uniqueidentifier)
    AS
     begin tran
     begin try
     
       
       delete from mb_friends where userid = @userid and friendid = @friendid
       
       update mb_profiles set friendscount = friendscount - 1
       where userid  = @userid;
       
       update mb_profiles set followerscount = followerscount - 1
       where userid = @friendid;
       
       commit tran
     end try
     begin catch
       rollback tran
       raiserror('Could Not Remove Friend',16,1);
     end catch
    
    
    CREATE PROCEDURE dbo.mb_updateuserprofile(@userid uniqueidentifier,@onlinebio nvarchar(200),@picturefile nvarchar(50))
    AS
        if  @picturefile <> ''
           update mb_profiles set picturefile = @picturefile, onlinebio = @onlinebio
           where userid = @userid;
        else
           update mb_profiles set onlinebio = @onlinebio
           where userid = @userid;
    
  13. In the Application Configuration Tool, go to Application Configuration.
  14. Select Configure SMTP Email settings
  15. Enter Server name as localhost and From as admin@systemname.com. Replace systemname with the name of your system
  16. Click on Save button
  17. Go to Solution Explorer and make login.aspx the startup page.
  18. Run project from Visual Studio.NET 2008 or Visual Web Developer 2008.
  19. You should see login.aspx page.
  20. Create new user using registration page and then login with that user name
  21. Test the rest of the options.