How we work on N tire architecture in asp.net Please give me
Examle...

Answers were Sorted based on User's Feedback



How we work on N tire architecture in asp.net Please give me Examle.....

Answer / vijayanand

What is n-Tier Architecture?
This is a very important topic to consider when developing
an application. Many elements need to be considered when
deciding on the architecture of the application, such as
performance, scalability and future development issues. When
you are deciding on which architecture to use, first decide
on which of the three aforementioned elements you think is
most valuable -- as some choices you make will impact on
others. For example, some choices that boost performance
will impact on the scalability or future development of your
design, etc.

Here we will talk generally about what n-Tier architecture
is, and then we will have a look at different n-Tier
architectures you can use to develop ASP.NET applications
and issues that arise relating to performance, scalability
and future development issues for each one.

Firstly, what is n-Tier architecture? N-Tier architecture
refers to the architecture of an application that has at
least 3 "logical" layers -- or parts -- that are separate.
Each layer interacts with only the layer directly below, and
has specific function that it is responsible for.

Why use n-Tier architecture? Because each layer can be
located on physically different servers with only minor code
changes, hence they scale out and handle more server load.
Also, what each layer does internally is completely hidden
to other layers and this makes it possible to change or
update one layer without recompiling or modifying other layers.

This is a very powerful feature of n-Tier architecture, as
additional features or change to a layer can be done without
redeploying the whole application. For example, by
separating data access code from the business logic code,
when the database servers change you only needs to change
the data access code. Because business logic code stays the
same, the business logic code does not need to be modified
or recompiled.

[Note] tier and layer mean the same thing [End Note]

An n-Tier application usually has three tiers, and they are
called the presentation tier, the business tier and the data
tier. Let's have a look at what each tier is responsible for.

Presentation Layer
Presentation Layer is the layer responsible for displaying
user interface and "driving" that interface using business
tier classes and objects. In ASP.NET it includes ASPX pages,
user controls, server controls and sometimes security
related classes and objects.

Business Tier
Business Tier is the layer responsible for accessing the
data tier to retrieve, modify and delete data to and from
the data tier and send the results to the presentation tier.
This layer is also responsible for processing the data
retrieved and sent to the presentation layer.

In ASP.NET it includes using SqlClient or OleDb objects to
retrieve, update and delete data from SQL Server or Access
databases, and also passing the data retrieved to the
presentation layer in a DataReader or DataSet object, or a
custom collection object. It might also include the sending
of just an integer, but the integer would have been
calculated using the data in the data tier such as the
number of records a table has.

BLL and DAL
Often this layer is divided into two sub layers: the
Business Logic Layer (BLL), and the Data Access Layers
(DAL). Business Logic Layers are above Data Access Layers,
meaning BLL uses DAL classes and objects. DAL is responsible
for accessing data and forwarding it to BLL.

In ASP.NET it might be using SqlClient or OleDb to retrieve
the data and sending it to BLL in the form of a DataSet or
DataReader. BLL is responsible for preparing or processing
the data retrieved and sends it to the presentation layer.
In ASP.NET it might be using the DataSet and DataReader
objects to fill up a custom collection or process it to come
up with a value, and then sending it to Presentation Layer.
BLL sometimes works as just transparent layer. For example,
if you want to pass a DataSet or DataReader object directly
to the presentation layer.

Data Tier
Data tier is the database or the source of the data itself.
Often in .NET it's an SQL Server or Access database, however
it's not limited to just those. It could also be Oracle,
mySQL or even XML. In this article we will focus on SQL
Server, as it has been proven to be the fastest database
within a .NET Application.

Logical Layers vs. Physical Layers (Distributed)
Logical Layers and Physical Layers are the ones that confuse
people. Firstly, a logical layer means that layers are
separate in terms of assembly or sets of classes, but are
still hosted on the same server. Physical layer means that
those assemblies or sets of classes are hosted on different
servers with some additional code to handle the
communication between the layers. E.g. remoting and web
services.

Deciding to separate the layers physically or not is very
important. It really depends on the load your application
expects to get. I think it's worth mentioning some of the
facts that might affect your decision.

Please DO note that separating the layers physically WILL
slow your application down due to the delay in communicating
between the servers throughout the network, so if you are
using the physical layer approach, make sure the performance
gain is worth the performance loss from this.

Hopefully you would have designed your application using the
n-Tier approach. If this is the case, then note that you can
separate the layers in the future.

Cost for deploying and maintaining physically separated
applications is much greater. First of all, you will need
more servers. You also need network hardware connecting
them. At this point, deploying the application becomes more
complex too! So decide if these things will be worth it or not.

Another fact that might affect your decision is how each of
the tiers in the application are going to be used. You will
probably want to host a tier on a separate server if more
than 1 service is dependent on it, e.g. You might want to
host business logic somewhere else if you have multiple
presentation layers for different clients. You might also
want a separate SQL server if you have other applications
using the same data.

Is This Answer Correct ?    47 Yes 7 No

How we work on N tire architecture in asp.net Please give me Examle.....

Answer / shivani

in n tier aaplication a project is devided ito laters.
commenly used 3 tier architecture used to devide layer into
User interface, logical and business. User interface use to
intract with end user. logical layer provide interface
between Uers interface layer and business layer. logical
layer is connected with database.
There is another 7 tier architecture. in this architure we
use Configustion layer,common layer, data layer,Db layer,
security layer, web and workflow layer.

Is This Answer Correct ?    18 Yes 8 No

How we work on N tire architecture in asp.net Please give me Examle.....

Answer / sandeep singh shekhawat

Class Library:-

Person.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Info
{
public class Person
{
public Person()
{
}
public string FirstName { get; set; }
public string LastName { get; set; }
public string Age { get; set; }
}
}


connection.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Info
{
public class connection
{
public SqlConnection conn;

public connection()
{
conn = new SqlConnection();
conn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\WebSite2\App_Data\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
}

}
}


Query.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Info
{
public class Query
{
connection con = new connection();
SqlCommand cmd;
public Query()
{
}
public int insert(Person p)
{
if (con.conn.State == ConnectionState.Closed)
con.conn.Open();
cmd = new SqlCommand("Insertdata", con.conn);
cmd.CommandType = CommandType.StoredProcedure;
try
{
cmd.Parameters.AddWithValue("@FirstName", p.FirstName);
cmd.Parameters.AddWithValue("@LastName", p.LastName);
cmd.Parameters.AddWithValue("@Age", p.Age);
return cmd.ExecuteNonQuery();
}
catch
{
throw;
}

}
}
}

PersonDAL.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Info
{
public class PersonDAL
{

public PersonDAL()
{
}

public int insert(Person p)
{
Query q = new Query();
try
{
return q.insert(p);
}
catch
{
throw;
}
}

}
}

Storeprocedure

ALTER PROCEDURE Insertdata
(
@FirstName varchar(50),
@LastName varchar(50),
@Age int
)
AS
INSERT INTO person(Fname,Lname,Age) VALUES (@FirstName,@LastName,@Age)


RETURN

Web page:

Person.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Info;

public partial class _Default : System.Web.UI.Page
{
Person p = new Person();
PersonDAL pd = new PersonDAL();
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
p.FirstName = TextBox1.Text;
p.LastName = TextBox2.Text;
p.Age = TextBox3.Text;
pd.insert(p);

}
}

Is This Answer Correct ?    11 Yes 1 No

Post New Answer

More ADO.NET Code Interview Questions

how to insert fname,lname,designation values into database while click on the submit button using windows authentication mode?

0 Answers  


Give me some tips in c#?

0 Answers  


How to update and insert from datagridview at run time in excel database?

0 Answers  


how to retrive file ,using file info on click event of a buton and disply it on a web form

1 Answers   Activa Softec,


In the Design view in Visual Studio 2005 of an ASP.NET web page, what is the easiest way to create an event handler for the default event of an ASP.NET server control?

1 Answers  






How we work on N tire architecture in asp.net Please give me Examle...

3 Answers   ABC, HCL, IBM,


How to connect c# visual studio 2008 to Oracle with ADO.NET? thanks for the answer.

1 Answers  


how to connect bind a control to database by writing a stored procedure?

3 Answers   Satyam,


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)