MicroBlog free asp.net project with source codes
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.
- Asp.Net 3.5
- C# Language
- SQL Server 2005 Express Edition
- Visual Studio.NET 2008
- Layered Architecture with Presentation Layer and Data Access Layer
- All database manipulations are done with stored procedures.
- Stored procedures are accessed using classes in DAL - Data Access Layer.
- ObjectDataSource is used in presentation layer to talk to DAL.
- DataList is used to display and delete data
- Membership and login controls are used to implement security.
- Master page and themes are used
- ADO.NET is used to access database
- User Registration
- Login
- Password Recovery
- Change password
- Home page
- Post an update
- List of user update
- Delete an update
- Finding people
- Adding friend
- Removing friend
- Changing the profile of the user
- Logout
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.- 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.
- Open Visual Studio.NET 2008 or Visual Web Developer 2008.
- Open the project from the directory into which you extracted project. For example, c:\microblog
- Select Website->ASP.NET Configuration option
- Select Security tab
- Select Use the security Setup Wizard to configure security step by step.
- Select From Internet option in Step 2
- Click on Next button in the remaining screens and finally click on Finish.
- It create a database called ASPNETDB.MDF with required tables and other database components
- Open the database in Server explorer or Database Explorer and create tables - MB_PROFILES, MB_FRIENDS, MB_UPDATESwith the following structure. The following tables show the structure of these tables. MB_PROFILES
userid uniqueidentifier (primary key)
MB_UPDATES
onlinebio varchar(200)
picturefile varchar(20)
followerscount int
friendscount int
updatescount int
Note : userid is linked with userid of ASPNET_USERS table.updateid int identify column (primary key)
MB_FRIENDS
userid uniqueidentifier
test varchar(140)
timestamp datetime
Note : userid is linked with userid of ASPNET_USERS table.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 - 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); - 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; - In the Application Configuration Tool, go to Application Configuration.
- Select Configure SMTP Email settings
- Enter Server name as localhost and From as admin@systemname.com. Replace systemname with the name of your system
- Click on Save button
- Go to Solution Explorer and make login.aspx the startup page.
- Run project from Visual Studio.NET 2008 or Visual Web Developer 2008.
- You should see login.aspx page.
- Create new user using registration page and then login with that user name
- Test the rest of the options.
EmoticonEmoticon