Today I would like to write about how to create Three-Tier architecture
Guys who have just started working on .net may have questions in their minds
What is this ‘three tier architecture?, Why three tier architecture? Why to follow it.? and so on……………….
I was in the same illusion when I have started working on .net and told to follow it.
There are many reasons to tell why we need an architecture .I want to tell you few of that I know:-
1) To make our code more modular.
2) Readability increases.
3) Fixing bugs is easier.
4) To follow certain standard’s.
I would like to illustrate how to and what is the need to follow.
Architecture may not be of three tiers always .It has been chosen to follow because it may be a clients request or company standards. But it is always better to have an architecture for your project and to follow specific standards through out the project.
Three tier architecture looks like.

1) UIL(User Interface Layer)
2) BLL(Business Logic Layer)
3) DAL(Data Access Layer)
Create two subfolders Named CompleteBuild(optional name) and Database.
Place all procedure in the database folder and create a folder called UIL in the CompleteBuild.
Creating Virtual Directory
Now go to run (windows key + r), type inetmgr then press enter.You will be able to view the IIS window as below.

On the left side of the window you can view local computer, expand it you will observe Web Sites and then choose Default Web Sites to expand .Move the mouse over Default Web Site link right click then select New option from that select and Click Virtual Directory.......
local computer -> Web Sites -> Default Web Site -> (right click and choose) New -> Virtual Directory
Now you will observe another window which will be similar to this image.
Click on next.
Now it will ask you to give alias name .Choose an appropraite name to fill the text box.
After filling text box click on next .

Now you need to enter physical path of your project where it is located.
like C:\OurSpace\Complete Build\UIL
After done, click on next.
Just check Browse option in the access permissions window and dont do any thing else.
Done with it, then click on next.
Virtual directory has been created successfully if you get this window.
Click on finish .

You can now see the virtual directory with the alias name you have given has been created in ths Defaut web sites (left side) and in the content side you will have no content but, if you are placing any files in UIL you can very well view them and browse depending upon the the permissions you have given in Access Permission Window.

you will be landing into this window choose ASP.NET Web Site or AJAX Enabled Web Site depending on your requirement.
Now look at the left-bottom of the window you will find location dropdown, select http then click on browse

you will find this window choose the physical directory you have just created.
Note:- you can only find virtual directory when you select IIS tab, which is located at the left side is selected.

Now we have to create two more layers BLL and DAL.These BLL and DAL are nothing but Class Library.Go to the solution explorer window, move your mouse on the Solution File then right click select Add -> Add New Project option you will find the window as shown .Choose
the location C:\OurSpace\CompleteBuildand name it as BLL.
Repeat the same for DAL layer.
We have created the three layers , now we need to set properties and relation among them.

Now go to the UIL right click to choose properties.
Choose Reference located at the left side.
when the window pops up click on Add Reference button.
Choose the projects tab, select BLL and
DAL(i have used EnterPrise Library instead of DAL)then click on ok.

Choose MS Build option from the left side and update Output Folders as C:\OurSpace\CompleteBuild\SolutionFiles\PrecompiledWeb\UIL and relate correspondingly yours donot exactly cut copy paste.

Go to solution file right click and choose properties select Project Dependencies tab located left side of the window.
select project
UIL
Check Depends On BLL
similarly select project BLL and check Depends On DAL and there is no need for DAL to set any property as it does not depend on any project, neither UIL nor BLL.
Now we have successfully created the specified architecture. If you haven't try, just try it you will surely make sense.


2 comments:
The concept of 3-Tier architecture was very lucidly written. Very useful for a layman to begin working on the .Net platform. Awaiting for more.....
HI FRIEND.U HAVE BRIEFLY EXPLAINED ABOUT 3-TIER ARCHITECTURE.CAN U PLEASE GIVE ONE EXAMPLE ON IT
Post a Comment